1 ! Copyright (C) 2010 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
4 USING: accessors arrays help help.markup help.topics
5 io.encodings.utf8 io.files io.pathnames kernel namespaces
6 pdf.canvas pdf.layout pdf.streams sequences sets strings ;
12 : next-articles ( str -- seq )
13 lookup-article content>> [ array? ] filter
14 [ first \ $subsections eq? ] filter
15 [ rest [ string? ] filter ] gather ;
17 : topic>pdf ( str -- pdf )
22 [ article-title $heading ]
23 [ article-content print-content ] bi
28 : topics>pdf ( seq -- pdf )
29 [ topic>pdf ] map <pb> 1array join ;
31 : write-pdf ( pdf name -- )
32 [ pdf>string ] dip home prepend-path utf8 set-file-contents ;
36 : article-pdf ( str name -- )
39 [ [ print-topic ] with-pdf-writer ]
40 [ next-articles topics>pdf ] bi
41 [ <pb> 1array glue ] unless-empty
46 "cookbook" "cookbook.pdf" article-pdf ;
48 : first-program-pdf ( -- )
49 "first-program" "first-program.pdf" article-pdf ;
52 "handbook-language-reference" "handbook.pdf" article-pdf ;
55 "handbook-system-reference" "system.pdf" article-pdf ;
58 "handbook-tools-reference" "tools" article-pdf ;
67 } topics>pdf "index.pdf" write-pdf ;
70 "furnace" "furnace.pdf" article-pdf ;
73 "alien" "alien.pdf" article-pdf ;
76 "io" "io.pdf" article-pdf ;