diff --git a/extra/fuel/help/help-docs.factor b/extra/fuel/help/help-docs.factor index 4f8772083f..6cbdcc27cc 100644 --- a/extra/fuel/help/help-docs.factor +++ b/extra/fuel/help/help-docs.factor @@ -12,3 +12,12 @@ HELP: get-article HELP: find-word { $values { "name" string } { "word/f" "word or f" } } { $description "Prefer to use search which takes the execution context into account. If that fails, fall back on a search of all words." } ; + +HELP: vocab-element +{ $values { "name" string } { "element" sequence } } +{ $description "Creates help markup for a vocab suitable for rendering with FUEL." } +{ $see-also article-element word-element } ; + +HELP: get-vocabs/tag +{ $values { "tag" string } { "element" sequence } } +{ $description "Creates help markup for a page listing all vocabs with a given tag." } ; diff --git a/extra/fuel/help/help-tests.factor b/extra/fuel/help/help-tests.factor index f0db961334..d8a75e21a4 100644 --- a/extra/fuel/help/help-tests.factor +++ b/extra/fuel/help/help-tests.factor @@ -34,3 +34,12 @@ IN: fuel.help.tests } [ "server-config" article-parents ] unit-test + +{ + { + { "handbook" "Factor handbook" article } + { "first-program" "Your first program" article } + } +} [ + "first-program-test" article-crumbs +] unit-test diff --git a/extra/fuel/help/help.factor b/extra/fuel/help/help.factor index 7031b66cc8..48500f5777 100644 --- a/extra/fuel/help/help.factor +++ b/extra/fuel/help/help.factor @@ -9,7 +9,10 @@ IN: fuel.help SYMBOLS: $doc-path $next-link $prev-link $fuel-nav-crumbs ; -: common-crumbs ( -- crumbs ) +: articles-crumbs ( seq -- crumbs ) + [ dup article-title \ article 3array ] map ; + +: base-crumbs ( -- crumbs ) { "handbook" "vocab-index" } [ dup article-title \ article 3array ] map ; : vocab-own-crumbs ( vocab-name -- crumbs ) @@ -19,7 +22,7 @@ SYMBOLS: $doc-path $next-link $prev-link $fuel-nav-crumbs ; [ dup "." split last \ vocab 3array ] map ; : vocab-crumbs ( vocab-name -- crumbs ) - vocab-own-crumbs common-crumbs prepend ; + vocab-own-crumbs base-crumbs prepend ; : article-parents ( article-name -- parents ) [ article-parent ] follow @@ -131,13 +134,19 @@ PRIVATE> : vocab-help ( name -- str ) dup empty? [ vocab-children-help ] [ vocab-element ] if ; +: add-crumb ( crumbs article -- crumbs' ) + dup article-name 2array suffix ; + +: simple-element ( title content crumbs -- element ) + \ $fuel-nav-crumbs prefix prefix \ article -rot 3array ; + : get-vocabs/author ( author -- element ) - [ "Vocabularies by " prepend \ $heading swap 2array ] - [ authored do-vocab-list ] bi 2array ; + [ "Vocabularies by " prepend ] [ authored do-vocab-list ] bi + base-crumbs "vocab-authors" add-crumb simple-element ; : get-vocabs/tag ( tag -- element ) - [ "Vocabularies tagged " prepend \ $heading swap 2array ] - [ tagged do-vocab-list ] bi 2array ; + [ "Vocabularies tagged " prepend ] [ tagged do-vocab-list ] bi + base-crumbs "vocab-tags" add-crumb simple-element ; : format-index ( seq -- seq ) [ [ >link name>> ] [ article-title ] bi 2array \ $subsection prefix ] map ; @@ -153,5 +162,5 @@ PRIVATE> : vocab-help-article? ( name -- ? ) dup lookup-vocab [ help>> = ] [ drop f ] if* ; -: get-article ( name -- str ) +: get-article ( name -- element ) dup vocab-help-article? [ vocab-help ] [ article-element ] if ;