shrub/pkg/arvo/lib/dprint.hoon

783 lines
20 KiB
Plaintext
Raw Normal View History

/- *sole
/+ easy-print=language-server-easy-print
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: a library for printing doccords
2022-06-30 23:58:45 +03:00
=/ debug |
=>
:: dprint-types
|%
:: $overview: an overview of all named things in the type.
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
::
:: each element in the overview list is either a documentation for a sublist
:: or an association betwen a term and documentation for it
+$ overview (list overview-item)
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: $overview-item: an element of an overview
+$ overview-item
$% [%header doc=what children=overview]
[%item name=tape doc=what]
==
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: $item: the part of a type being inspected
+$ item
$%
:: overview of a type
::
[%view items=overview]
:: inspecting a full core
$: %core
name=tape :: arm that built it
docs=what ::
sut=type :: [%core *]
children=(unit item) :: compiled against
==
:: inspecting a single arm on a core
$: %arm
name=tape :: arm name
adoc=what :: arm doc
pdoc=what :: product doc
cdoc=what :: $ arm/prod doc
gen=hoon :: arm hoon AST
sut=type :: subject of arm
==
:: inspecting a face and what's behind it
$: %face
name=tape :: name of face
docs=what ::
children=(unit item) :: face referent
==
:: inspecting a single chapter on a core
$: %chapter
name=tape :: name of chapter
docs=what ::
sut=type :: [%core *]
tom=tome :: tome of chapter
==
==
::
--
:: dprint
::
:: core containing doccords search and printing utilities
|%
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: contains arms used for looking for docs inside of a type
::
:: the entrypoint for finding docs within a type is +find-item-in-type.
+| %searching
:: +find-item-in-type: returns the item to print while searching through topic
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
::
:: this gate is a thin wrapper around _hunt for usability, since the only entry
:: point most users should care about is find-item:hunt
::
++ find-item-in-type
|= [topics=(list term) sut=type]
?~ topics !!
=/ top=(lest term) topics
~(find-item hunt [top sut])
::
:: +hunt: door used for refining the type while searching for doccords
::
++ hunt
=| gil=(set type)
|_ [topics=(lest term) sut=type]
+* this .
::
+| %find
::
++ find-item
~? >> debug %find-item
^- (unit item)
?- sut
%noun ~
%void ~
[%atom *] ~
[%cell *] find-cell
[%core *] find-core
[%face *] find-face
[%fork *] find-fork
[%hint *] find-hint
[%hold *] find-item:this(sut (~(play ut p.sut) q.sut))
==
::
++ find-cell
~? >> debug %find-cell
2022-12-07 23:20:23 +03:00
^- (unit item)
?> ?=([%cell *] sut)
=/ lhs find-item:this(sut p.sut)
?~ lhs
find-item:this(sut q.sut)
lhs
::
++ find-core
~? >> debug %find-core
2022-12-07 23:20:23 +03:00
^- (unit item)
?> ?=([%core *] sut)
?: check-arm
?: check-search
?: check-arm-core
return-arm-core
return-arm
recurse-arm-core
?: check-chap
?: check-search
return-chap
recurse-chap
recurse-core
::
++ find-face
~? >> debug %find-face
2022-12-07 23:20:23 +03:00
^- (unit item)
?> ?=([%face *] sut)
?. ?=(term p.sut)
::TODO: handle $tune case
find-item:this(sut q.sut)
?. =(i.topics p.sut)
~
?~ t.topics
return-face
find-item:this(sut q.sut, topics t.topics)
::
++ find-fork
~? >> debug %find-fork
2022-12-07 23:20:23 +03:00
^- (unit item)
?> ?=([%fork *] sut)
=/ types=(list type) ~(tap in p.sut)
|-
?~ types ~
=+ res=find-item:this(sut i.types)
?~ res
$(types t.types)
res
::
++ find-hint
~? >> debug %find-hint
2022-12-07 23:20:23 +03:00
^- (unit item)
|^
?> ?=([%hint *] sut)
?. ?=([%help *] q.p.sut)
find-item:this(sut q.sut)
?+ q.sut ~
[%cell *] find-cell:this(sut q.sut)
[%core *] find-hint-core
[%face *] find-hint-face
[%fork *] find-fork:this(sut q.sut)
[%hint *] find-hint:this(sut q.sut)
[%hold *] find-hint:this(q.sut (~(play ut p.q.sut) q.q.sut))
==
::
++ find-hint-core
~? >> debug %find-hint-core
2022-12-07 23:20:23 +03:00
^- (unit item)
?> &(?=([%hint *] sut) ?=([%help *] q.p.sut) ?=([%core *] q.sut))
::
?. ?& ((sane %tas) summary.crib.p.q.p.sut)
=(summary.crib.p.q.p.sut i.topics)
==
find-core:this(sut q.sut)
?~ t.topics
return-hint-core
find-item:this(sut q.sut, topics t.topics)
::
++ find-hint-face
~? >> debug %find-hint-face
2022-12-07 23:20:23 +03:00
^- (unit item)
?> &(?=([%hint *] sut) ?=([%help *] q.p.sut) ?=([%face *] q.sut))
?: check-face:this(sut q.sut)
?~ t.topics
return-hint-face
find-item:this(sut q.q.sut, topics t.topics)
find-item:this(sut q.q.sut)
--
::
::+| %recurse
++ recurse-core
~? >> debug %recurse-core
2022-12-07 23:20:23 +03:00
^- (unit item)
?> ?=([%core *] sut)
find-item:this(sut p.sut)
++ recurse-chap
~? >> debug %recurse-chap
2022-12-07 23:20:23 +03:00
^- (unit item)
?> ?=([%core *] sut)
?~ t.topics !!
find-item:this(topics t.topics)
++ recurse-arm-core
~? >> debug %recurse-arm-core
2022-12-07 23:20:23 +03:00
^- (unit item)
?> ?=([%core *] sut)
?~ t.topics !!
find-item:this(sut arm-type, topics t.topics)
::
+| %check
::
++ check-arm
~? >> debug %recurse-core
2022-12-07 23:20:23 +03:00
^- ?
!=(~ (find ~[i.topics] (sloe sut)))
++ check-chap
~? >> debug %check-chap
2022-12-07 23:20:23 +03:00
^- ?
?> ?=([%core *] sut)
(~(has by q.r.q.sut) i.topics)
++ check-face
~? >> debug %check-face
2022-12-07 23:20:23 +03:00
^- ?
?> ?=([%face *] sut)
?. ?=(term p.sut)
::TODO: handle $tune case
%.n
=(p.sut i.topics)
++ check-search
~? >> debug %check-search
2022-12-07 23:20:23 +03:00
^- ?
=(~ t.topics)
++ check-arm-core
~? >> debug %check-arm-core
^- ?
=+ arm-list=(sloe (~(play ut sut) arm-hoon))
&(!=(arm-list ~) !=(arm-list ~[%$]) ?=([%core *] arm-type))
::
+| %return
::
++ return-cell
~? >>> debug %return-cell
^- (unit item)
?> ?=([%cell *] sut)
(join-items return-item:this(sut p.sut) return-item:this(sut q.sut))
::
++ return-core
~? >>> debug %return-core
^- (unit item)
?> ?=([%core *] sut)
=* compiled-against return-item:this(sut p.sut)
`[%core (trip i.topics) *what sut compiled-against]
::
++ return-face
~? >>> debug %return-face
^- (unit item)
?> ?=([%face *] sut)
:: TODO: handle tune case
?. ?=(term p.sut)
return-item:this(sut q.sut)
=* compiled-against return-item:this(sut q.sut)
`[%face (trip p.sut) *what compiled-against]
::
++ return-fork
~? >>> debug %return-fork
^- (unit item)
?> ?=([%fork *] sut)
=* types ~(tap in p.sut)
=* items (turn types |=(a=type return-item:this(sut a)))
(roll items join-items)
::
++ return-hint
~? >>> debug %return-hint
^- (unit item)
?> ?=([%hint *] sut)
=* res return-item:this(sut q.sut)
?. ?=([%help *] q.p.sut)
~
?: ?=([%core *] q.sut)
return-hint-core
?: ?=([%face *] q.sut)
return-hint-face
`[%view [%header `crib.p.q.p.sut (item-as-overview res)]~]
::
++ return-arm
~? >>> debug %return-arm
^- (unit item)
?> ?=([%core *] sut)
=+ [adoc pdoc cdoc]=(arm-docs i.topics sut)
::TODO: should this p.sut be sut? or the compiled type of the arm?
`[%arm (trip i.topics) adoc pdoc cdoc arm-hoon sut]
::
++ return-chap
~? >>> debug %return-chap
^- (unit item)
?> ?=([%core *] sut)
=/ tom=tome (~(got by q.r.q.sut) i.topics)
`[%chapter (trip i.topics) p.tom sut (~(got by q.r.q.sut) i.topics)]
::
++ return-arm-core
~? >>> debug %return-arm-core
^- (unit item)
?> ?=([%core *] sut)
=+ [adoc pdoc cdoc]=(arm-docs i.topics sut)
=/ dox=what ?~(adoc ?~(pdoc ~ pdoc) adoc)
=/ at arm-type
?> ?=([%core *] at)
=* compiled-against return-item:this(sut p.sut)
`[%core (trip i.topics) dox at compiled-against]
::
++ return-item
~? >>> debug %return-item
^- (unit item)
?- sut
%noun ~
%void ~
[%atom *] ~
[%cell *] return-cell
[%core *] return-core
[%face *] return-face
[%fork *] return-fork
[%hint *] return-hint
[%hold *]
?: (~(has in gil) sut)
~
=< return-item
%= this
gil (~(put in gil) sut)
sut (~(play ut p.sut) q.sut)
==
==
::
++ return-hint-core
~? >>> debug %return-hint-core
^- (unit item)
?> &(?=([%hint *] sut) ?=([%core *] q.sut))
(apply-hint return-core:this(sut q.sut))
::
++ return-hint-face
~? >>> debug %return-hint-face
^- (unit item)
?> &(?=([%hint *] sut) ?=([%face *] q.sut))
(apply-hint return-face:this(sut q.sut))
::
++ apply-hint
~? >> debug %apply-hint
|= uit=(unit item)
^- (unit item)
?~ uit ~
?> &(?=([%hint *] sut) ?=([%help *] q.p.sut))
?+ u.uit ~
?([%core *] [%face *]) (some u.uit(docs `crib.p.q.p.sut))
==
::
+| %misc
++ arm-hoon
^- hoon
?> ?=([%core *] sut)
(^arm-hoon i.topics sut)
::
++ arm-type
^- type
?> ?=([%core *] sut)
(^arm-type i.topics sut)
--
::
:: +arm-hoon: looks for an arm in a core type and returns its hoon
++ arm-hoon
|= [nom=term sut=type]
^- hoon
?> ?=([%core *] sut)
=/ tomes=(list [p=term q=tome]) ~(tap by q.r.q.sut)
|-
?~ tomes !!
=+ gen=(~(get by q.q.i.tomes) nom)
?~ gen
$(tomes t.tomes)
u.gen
::
:: +arm-type: looks for an arm in a core type and returns its type
++ arm-type
|= [nom=term sut=type]
^- type
?> ?=([%core *] sut)
(~(play ut sut) (arm-hoon nom sut))
::
:: +hint-doc: returns docs if type is %help $hint w/ matching cuff
++ hint-doc
|= [=cuff sut=type]
^- what
?. &(?=([%hint *] sut) ?=([%help *] q.p.sut) =(cuff cuff.p.q.p.sut))
~
`crib.p.q.p.sut
::
:: +arm-doc: returns arm doc of an arm
::
:: we just check if the $cuff is from a ++ or +$ arm but this will
:: probably need to be revisited once more sophisticated cuffs are used
++ arm-doc
|= [nom=term sut=type]
^- what
?~ (hint-doc [%funk nom]~ sut)
(hint-doc [%plan nom]~ sut)
(hint-doc [%funk nom]~ sut)
::
:: +prod-doc: wrapper for +hint-doc with empty cuff
++ prod-doc
|= sut=type
^- what
(hint-doc ~ sut)
::
:: +buc-doc: checks if type is core and returns docs on $ arm if it exists
++ buc-doc
|= sut=type
^- what
?. ?=([%core *] sut)
~
?~ (find [%$]~ (sloe sut))
~
=/ sat=type (arm-type %$ sut)
?~ (arm-doc %$ sat)
(prod-doc sat)
(arm-doc %$ sat)
::
:: +arm-docs: grabs the docs for an arm.
::
:: there are three possible places with relevant docs for an arm:
:: docs for the arm itself, docs for the product of the arm, and
:: if the arm builds a core, docs for the default arm of that core.
::
:: .adoc: docs written above the the arm
:: .pdoc: docs for the product of the arm
:: .cdoc: docs for the default arm of the core produced by the arm
++ arm-docs
|= [nom=term sut=type]
^- [what what what]
?> ?=([%core *] sut)
=/ sat=type (~(play ut sut) (arm-hoon nom sut))
=/ adoc=what (arm-doc nom sat)
=/ pdoc=what
?~ adoc
(prod-doc sat)
?> ?=([%hint *] sat)
(prod-doc q.sat)
=/ cdoc=what
?~ adoc
?~ pdoc
(buc-doc sat)
?> ?=([%hint *] sat)
(buc-doc q.sat)
?~ pdoc
?> ?=([%hint *] sat)
(buc-doc q.sat)
?> &(?=([%hint *] sat) ?=([%hint *] q.sat))
(buc-doc q.q.sat)
[adoc pdoc cdoc]
::
:: +arm-and-chapter-overviews: returns an overview of a core's contents
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
::
:: returns an overview for arms which are part of unnamed chapters, and
:: an overview of the named chapters
::
++ arm-and-chapter-overviews
|= =item
^- [overview overview]
?> &(?=([%core *] item) ?=([%core *] sut.item))
=| [adocs=overview cdocs=overview]
=/ tomes ~(tap by q.r.q.sut.item)
|-
?~ tomes
[(sort-overview adocs) (sort-overview cdocs)]
?~ p.i.tomes
:: chapter has no name. add documentation for its arms to arm-docs
=. adocs (weld adocs (tome-as-overview q.i.tomes sut.item))
$(tomes t.tomes)
:: chapter has a name. add to list of chapters
=. cdocs
%+ weld cdocs
^- overview
[%item :(weld "^" name.item "|" (trip -.i.tomes)) p.q.i.tomes]~
$(tomes t.tomes)
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: +arms-in-chapter: returns an overview of the arms in a specific chapter
2022-03-30 22:36:30 +03:00
++ arms-in-chapter
|= [sut=type tom=tome]
2022-03-30 22:36:30 +03:00
^- overview
(sort-overview (tome-as-overview tom sut))
2022-03-30 22:36:30 +03:00
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: +sort-overview: sort items in an overview in alphabetical order
2022-03-30 22:36:30 +03:00
++ sort-overview
|= ovr=overview
^- overview
%+ sort ovr
|= [lhs=overview-item rhs=overview-item]
(aor (get-overview-name lhs) (get-overview-name rhs))
2022-03-30 22:36:30 +03:00
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: +get-overview-name: returns the name of an overview
2022-03-30 22:36:30 +03:00
++ get-overview-name
|= ovr=overview-item
?- ovr
[%header *] ""
[%item *] name.ovr
==
::
:: +tome-as-overview: translate a tome into an overview
++ tome-as-overview
|= [tom=tome sut=type]
2022-03-30 22:36:30 +03:00
^- overview
%+ turn ~(tap by q.tom)
|= ar=(pair term hoon)
:* %item
::TODO make this distinguish between ++ and +$ arms
(weld "+" (trip p.ar))
=/ adoc (arm-doc p.ar (~(play ut sut) q.ar))
=/ pdoc (prod-doc (~(play ut sut) q.ar))
?~ adoc
pdoc
adoc
==
2022-03-30 22:36:30 +03:00
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: +item-as-overview: changes an item into an overview
++ item-as-overview
|= uit=(unit item)
~? >> debug %item-as-overview
^- overview
?~ uit ~
=+ itm=(need uit)
?- itm
[%view *] items.itm
::
[%core *]
?~ name.itm
(item-as-overview children.itm)
:- [%item (weld "^" name.itm) docs.itm]
(item-as-overview children.itm)
::
[%arm *]
:_ ~
::TODO make this distinguish between ++ and +$ arms
:* %item (weld "+" name.itm)
?~ adoc.itm
?~ pdoc.itm
cdoc.itm
pdoc.itm
adoc.itm
==
::
[%chapter *]
[%item (weld "|" name.itm) docs.itm]~
::
[%face *]
?~ name.itm
~
[%item (weld "." name.itm) docs.itm]~
==
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: +join-items: combines two (unit items) together
++ join-items
|= [lhs=(unit item) rhs=(unit item)]
^- (unit item)
?~ lhs rhs
?~ rhs lhs
`[%view (weld (item-as-overview lhs) (item-as-overview rhs))]
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: contains arms using for printing doccords items
+| %printing
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: +print-item: prints a doccords item
2022-03-30 22:36:30 +03:00
++ print-item
|= =item
2022-04-07 20:05:58 +03:00
~? >> debug %print-item
2022-06-30 22:14:56 +03:00
^- (list sole-effect)
2022-03-30 22:36:30 +03:00
?- item
[%view *] (print-overview item *(pair styl styl))
[%core *] (print-core item)
[%arm *] (print-arm item)
[%chapter *] (print-chapter item)
[%face *] (print-face item)
2022-03-30 22:36:30 +03:00
==
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: +print-core: renders documentation for a full core
2022-03-30 22:36:30 +03:00
++ print-core
|= =item
2022-06-30 22:14:56 +03:00
^- (list sole-effect)
?> ?=([%core *] item)
=+ [arms chapters]=(arm-and-chapter-overviews item)
2022-06-30 22:14:56 +03:00
=/ styles=(pair styl styl) [[`%br ~ `%b] [`%br ~ `%m]]
2022-04-01 00:35:50 +03:00
;: weld
(print-header (weld "^" name.item) docs.item)
2022-04-01 00:35:50 +03:00
::
[%txt ""]~
::
(print-signature ~(duck easy-print sut.item))
::
[%txt ""]~
::
?~ arms
2022-04-01 00:35:50 +03:00
~
(print-overview [%view [%header `['arms:' ~] arms]~] styles)
2022-04-01 00:35:50 +03:00
::
?~ chapters
~
(print-overview [%view [%header `['chapters:' ~] chapters]~] styles)
2022-04-01 00:35:50 +03:00
::
?~ children.item
~
=/ child ?: ?=([%core *] u.children.item)
u.children.item(children ~)
?: ?=([%face *] u.children.item)
u.children.item(children ~)
u.children.item
=+ compiled=(item-as-overview `child)
2022-04-01 00:35:50 +03:00
?~ compiled
~
(print-overview [%view [%header `['compiled against: ' ~] [i.compiled]~]~] styles)
2022-04-01 00:35:50 +03:00
==
2022-03-30 22:36:30 +03:00
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: +print-chapter: renders documentation for a single chapter
2022-03-30 22:36:30 +03:00
++ print-chapter
|= =item
2022-06-30 22:14:56 +03:00
^- (list sole-effect)
?> ?=([%chapter *] item)
~? > debug %print-chapter
2022-06-30 22:14:56 +03:00
=/ styles=(pair styl styl) [[`%br ~ `%b] [`%br ~ `%m]]
2022-03-30 22:36:30 +03:00
;: weld
(print-header (weld "|" name.item) docs.item)
2022-03-30 22:36:30 +03:00
::
=+ arms=(arms-in-chapter sut.item tom.item)
2022-03-30 22:36:30 +03:00
?~ arms
~
(print-overview [%view [%header `['arms:' ~] arms]~] styles)
2022-03-30 22:36:30 +03:00
==
::
:: +print-signature: turns product of duck:easy-print into a (list sole-effect)
++ print-signature
|= =tank
^- (list sole-effect)
=/ tan (wash [3 80] tank)
?. (gte (lent tan) 3)
(turn tan |=(a=tape [%txt a]))
%+ weld
(turn (scag 3 tan) |=(a=tape [%txt a]))
(styled [[`%br ~ `%g] ' ...']~)
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: +print-arm: renders documentation for a single arm in a core
2022-03-30 22:36:30 +03:00
++ print-arm
|= =item
2022-06-30 22:14:56 +03:00
^- (list sole-effect)
?> ?=([%arm *] item)
~? >> debug %print-arm
;: weld
(print-header (weld "+" name.item) adoc.item)
[%txt ""]~
::
(print-signature ~(duck easy-print (~(play ut sut.item) gen.item)))
::
[%txt ""]~
::
?~ pdoc.item
*(list sole-effect)
%- zing :~ (styled [[`%br ~ `%b] 'product:']~)
(print-header "" pdoc.item)
[%txt ""]~
==
::
?~ cdoc.item
*(list sole-effect)
2022-12-15 23:06:02 +03:00
%- zing :~ (styled [[`%br ~ `%b] '$:']~)
(print-header "" cdoc.item)
==
==
2022-03-30 22:36:30 +03:00
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: +print-face: renders documentation for a face
2022-03-30 22:36:30 +03:00
++ print-face
|= =item
2022-06-30 22:14:56 +03:00
^- (list sole-effect)
?> ?=([%face *] item)
2022-04-07 20:05:58 +03:00
~? >> debug %print-face
2022-06-30 22:14:56 +03:00
;: weld
(print-header (weld "." name.item) docs.item)
[%txt ""]~
::
?~ children.item
2022-03-30 22:36:30 +03:00
~
(print-item u.children.item)
2022-06-30 22:14:56 +03:00
==
2022-03-30 22:36:30 +03:00
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: +print-header: prints name and docs only
2022-03-30 22:36:30 +03:00
++ print-header
|= [name=tape doc=what]
2022-06-30 22:14:56 +03:00
^- (list sole-effect)
2022-04-07 20:05:58 +03:00
~? >> debug %print-header
2022-06-30 22:14:56 +03:00
;: weld
(styled [[`%br ~ `%g] (crip name)]~)
?~ doc *(list sole-effect)
:: (styled [[`%br ~ `%r] '(undocumented)']~)
2022-06-30 22:14:56 +03:00
:~ :- %tan
%- flop
2022-06-30 22:14:56 +03:00
;: weld
[%leaf "{(trip p.u.doc)}"]~
(print-sections q.u.doc)
== ==
==
2022-03-30 22:36:30 +03:00
::
:: +print-overview: prints summaries of several items
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
::
:: the (pair styl styl) provides styles for each generation of child items
2022-03-30 22:36:30 +03:00
++ print-overview
|= [view=item styles=(pair styl styl)]
?> ?=([%view *] view)
2022-04-07 20:05:58 +03:00
~? >> debug %print-overview
=| out=(list sole-effect)
|- ^- (list sole-effect)
?~ items.view out
=/ oitem i.items.view
?- oitem
[%header *]
%= $
items.view t.items.view
out ;: weld
out
?~ doc.oitem ~
(styled [p.styles (crip "{(trip p.u.doc.oitem)}")]~)
^$(view [%view children.oitem])
== ==
::
[%item *]
%= $
items.view t.items.view
out ;: weld
out
(styled [q.styles (crip name.oitem)]~)
?~ doc.oitem
%- styled
:~ [[`%br ~ `%r] '(undocumented)']
[[~ ~ ~] '']
==
^- (list sole-effect)
[%tan [[%leaf ""] [%leaf "{(trip p.u.doc.oitem)}"] ~]]~
== ==
==
::
:: +print-sections: renders a list of sections as tang
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
::
:: prints the longform documentation
++ print-sections
|= sections=(list sect)
^- tang
=| out=tang
|-
?~ sections out
=. out
;: weld
out
`tang`[%leaf ""]~
(print-section i.sections)
==
$(sections t.sections)
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: +print-section: renders a sect as a tang
++ print-section
|= section=sect
^- tang
%+ turn section
|= =pica
^- tank
?: p.pica
[%leaf (trip q.pica)]
[%leaf " {(trip q.pica)}"]
2022-06-30 22:14:56 +03:00
::
hoon, dprint: change doccords syntax to :: this constitutes a pretty major rework of how whitespace is handled in hoon in order to change the doccords syntax from :> and :< to ::. in summary: throughout the hoon parser (+vast) many instances of +gap have been replaced by +jump, which first tries to remove whitespace (+leap) until it arrives at something that can be parsed as a prefix doccord (+apex:docs:vast). if it does not encounter a doccord, it instead uses +gap as normal. if you follow along with the parser, you will notice that every time jump is called, it then tries to call +apex:docs via +scye or +seam. if apex:docs succeeds, it will end up consuming a newline at the end, hiding the fact that there was valid whitespace from the parser. thus +apex:docs then inserts a newline after successfully parsing a prefix doccord, which will then be consumed by a subsequent invocation of +gap, ensuring that there was proper whitespace if the doccord would have been consumed by +gap instead of +leap. there are a few other changes: +hint in the compiler throws out doccords attached to %noun types. this was already the behavior before doccords, and the change was made before i understood what i was doing. similarly for commenting out the %note case in +open:ap - this was an earlier mistake postfix comments for chapters are now enabled. +expx was unused and removed in order to be rid of the convention-defying +exp1. other unused +ex(p/q)* were commented out. arms that handle batch comments (+glow and +whap) were refactored +toad, which was used to change between tall and wide form, tries to +jump before +gap. since +jump is ;~(pose leap:docs gap), i would have thought that just using +jump there would be fine, but it fails for some reason. some parsers built with |@ were rewritten to use |* |$ was made so that any doccords put on the spec are converted into hoon doccords on the $ arm. it wouldn't compile otherwise. there's probably a more principled way to do this but it works fine for now.
2022-07-19 21:57:36 +03:00
:: +styled: makes $sole-effects out of $styls and $cords
2022-06-30 22:14:56 +03:00
++ styled
|= [in=(list (pair styl cord))]
^- (list sole-effect)
=| out=(list sole-effect)
|-
?~ in out
=/ eff=styx [p.i.in [q.i.in]~]~
%= $
in t.in
out (snoc out [%klr eff])
==
--