diff --git a/extra/fuel/help/help-docs.factor b/extra/fuel/help/help-docs.factor index 7b6a743345..4f8772083f 100644 --- a/extra/fuel/help/help-docs.factor +++ b/extra/fuel/help/help-docs.factor @@ -1,6 +1,10 @@ -USING: fuel.help.private help.markup help.syntax strings ; +USING: fuel.help.private help.markup help.syntax sequences strings ; IN: fuel.help +HELP: article-parents +{ $values { "article-name" string } { "parents" sequence } } +{ $description "All the parent articles for the article and ensures that the ancestor always is 'handbook'." } ; + HELP: get-article { $values { "name" string } { "str" string } } { $description "If an article and a vocab share name, we render the vocab instead." } ; diff --git a/extra/fuel/help/help-tests.factor b/extra/fuel/help/help-tests.factor index 629c3aa909..f0db961334 100644 --- a/extra/fuel/help/help-tests.factor +++ b/extra/fuel/help/help-tests.factor @@ -28,3 +28,9 @@ IN: fuel.help.tests "io" vocab-help-article? "help.lint" vocab-help-article? ] unit-test + +{ + { "handbook" "io.servers" } +} [ + "server-config" article-parents +] unit-test diff --git a/extra/fuel/help/help.factor b/extra/fuel/help/help.factor index b7b7d05a67..7031b66cc8 100644 --- a/extra/fuel/help/help.factor +++ b/extra/fuel/help/help.factor @@ -12,15 +12,23 @@ SYMBOLS: $doc-path $next-link $prev-link $fuel-nav-crumbs ; : common-crumbs ( -- crumbs ) { "handbook" "vocab-index" } [ dup article-title \ article 3array ] map ; -: vocab-own-crumbs ( vocab -- crumbs ) +: vocab-own-crumbs ( vocab-name -- crumbs ) "." split unclip [ [ CHAR: . suffix ] dip append ] accumulate swap suffix [ dup "." split last \ vocab 3array ] map ; -: vocab-crumbs ( vocab -- crumbs ) +: vocab-crumbs ( vocab-name -- crumbs ) vocab-own-crumbs common-crumbs prepend ; +: article-parents ( article-name -- parents ) + [ article-parent ] follow + dup last "handbook" = [ "handbook" suffix ] unless + reverse but-last ; + +: article-crumbs ( article-name -- crumbs ) + article-parents [ dup article-title \ article 3array ] map ; + : format-index ( seq -- seq ) [ [ >link name>> ] [ article-title ] bi 2array \ $subsection prefix ] map ; +: article-element ( name -- element ) + \ article swap dup lookup-article + [ nip title>> ] + [ + [ article-crumbs \ $fuel-nav-crumbs prefix ] [ content>> ] bi* + \ $nl prefix swap prefix + ] 2bi 3array ; + : vocab-help-article? ( name -- ? ) dup lookup-vocab [ help>> = ] [ drop f ] if* ; : get-article ( name -- str ) - dup vocab-help-article? [ vocab-help ] [ lookup-article ] if ; + dup vocab-help-article? [ vocab-help ] [ article-element ] if ;