factor/extra/help/pdf/pdf.factor

75 lines
1.8 KiB
Factor
Raw Normal View History

! Copyright (C) 2010 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: accessors arrays assocs help help.markup help.topics
io.encodings.utf8 io.files io.pathnames kernel pdf pdf.layout
pdf.streams sequences sets strings ;
IN: help.pdf
<PRIVATE
: next-articles ( str -- seq )
lookup-article content>> [ array? ] filter
[ first \ $subsections eq? ] filter
[ rest [ string? ] filter ] gather ;
: topic>pdf ( str -- pdf )
[
[ print-topic ]
[
next-articles [
[ article-title $heading ]
[ article-content print-content ] bi
] each
] bi
] with-pdf-writer ;
: topics>pdf ( seq -- pdf )
[ topic>pdf ] map <pb> 1array join ;
: write-pdf ( pdf name -- )
2018-02-26 20:29:10 -05:00
[ pdf>string ] dip utf8 set-file-contents ;
PRIVATE>
: article-pdf ( str name -- )
[
[ [ print-topic ] with-pdf-writer ]
[ next-articles topics>pdf ] bi
[ <pb> 1array glue ] unless-empty
] [ write-pdf ] bi* ;
: cookbook-pdf ( -- )
2018-02-26 20:29:10 -05:00
"cookbook" "~/cookbook.pdf" article-pdf ;
: first-program-pdf ( -- )
2018-02-26 20:29:10 -05:00
"first-program" "~/first-program.pdf" article-pdf ;
: handbook-pdf ( -- )
2018-02-26 20:29:10 -05:00
"handbook-language-reference" "~/handbook.pdf" article-pdf ;
: system-pdf ( -- )
2018-02-26 20:29:10 -05:00
"handbook-system-reference" "~/system.pdf" article-pdf ;
: tools-pdf ( -- )
2018-02-26 20:29:10 -05:00
"handbook-tools-reference" "~/tools.pdf" article-pdf ;
: index-pdf ( -- )
{
"vocab-index"
"article-index"
"primitive-index"
"error-index"
"class-index"
2018-02-26 20:29:10 -05:00
} topics>pdf "~/index.pdf" write-pdf ;
2012-12-16 20:10:02 -05:00
: furnace-pdf ( -- )
2018-02-26 20:29:10 -05:00
"furnace" "~/furnace.pdf" article-pdf ;
2012-12-16 20:10:02 -05:00
: alien-pdf ( -- )
2018-02-26 20:29:10 -05:00
"alien" "~/alien.pdf" article-pdf ;
2012-12-16 20:10:02 -05:00
: io-pdf ( -- )
2018-02-26 20:29:10 -05:00
"io" "~/io.pdf" article-pdf ;