! Copyright (C) 2008, 2011 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: checksums checksums.sha io.encodings.utf8 io.encodings.binary io.encodings.string io.files io.files.temp io.directories html.streams help help.home kernel assocs sequences make words accessors arrays help.topics vocabs vocabs.hierarchy help.vocabs namespaces io vocabs.loader serialize fry memoize unicode.case math.order sorting debugger html xml.syntax xml.writer math.parser sets hashtables ; FROM: io.encodings.ascii => ascii ; FROM: ascii => ascii? ; IN: help.html GENERIC: topic>filename* ( topic -- name prefix ) M: word topic>filename* dup vocabulary>> [ [ name>> ] [ vocabulary>> ] bi 2array "word" ] [ drop f f ] if ; M: link topic>filename* name>> dup [ "article" ] [ topic>filename* ] if ; M: word-link topic>filename* name>> topic>filename* ; M: vocab-spec topic>filename* vocab-name "vocab" ; M: vocab-tag topic>filename* name>> "tag" ; M: vocab-author topic>filename* name>> "author" ; M: f topic>filename* drop \ f topic>filename* ; : topic>filename ( topic -- filename ) topic>filename* dup [ [ % "-" % dup array? [ "," join ] when utf8 encode sha1 checksum-bytes hex-string % ".html" % ] "" make ] [ 2drop f ] if ; M: topic url-of topic>filename ; : help-stylesheet ( -- xml ) "vocab:help/html/stylesheet.css" ascii file-contents [XML XML] ; : help-navbar ( -- xml ) [XML
XML] ; : help>html ( topic -- xml ) [ article-title " - Factor Documentation" append ] [ drop help-stylesheet ] [ [ help-navbar ] [ [ print-topic ] with-html-writer ] bi* append ] tri simple-page ; : generate-help-file ( topic -- ) dup topic>filename utf8 [ help>html write-xml ] with-file-writer ; : all-vocabs-really ( -- seq ) all-vocabs-recursive >hashtable no-roots remove-redundant-prefixes [ vocab-name "scratchpad" = not ] filter ; : all-topics ( -- topics ) [ articles get keys [ >link ] map % all-words [ >link ] map % all-authors [