mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-05 05:45:46 +03:00
doccords: dprint refactoring and renaming
This commit is contained in:
parent
6f32d107fc
commit
37a787970c
@ -256,56 +256,76 @@
|
|||||||
$(tomes t.tomes)
|
$(tomes t.tomes)
|
||||||
`u.gen
|
`u.gen
|
||||||
::
|
::
|
||||||
:> gets the documentation inside of a type
|
:> gets the documentation inside of a hint, or a hold that plays to a hint
|
||||||
++ what-from-type
|
++ what-from-hint
|
||||||
:> testing
|
|
||||||
|= sut=type
|
|= sut=type
|
||||||
^- what
|
^- what
|
||||||
?+ sut
|
?+ sut
|
||||||
~
|
~
|
||||||
::
|
|
||||||
[%core *]
|
|
||||||
~? >> debug %what-from-type-core ~ :: should this get the chapter docs?
|
|
||||||
::
|
::
|
||||||
[%hold *]
|
[%hold *]
|
||||||
~? >> debug %what-from-type-hold $(sut (~(play ut p.sut) q.sut))
|
~? >> debug %what-from-hint-hold $(sut (~(play ut p.sut) q.sut))
|
||||||
::
|
::
|
||||||
[%hint *]
|
[%hint *]
|
||||||
~? >> debug :- %what-from-type-hint -.q.p.sut
|
~? >> debug :- %what-from-hint-hint -.q.p.sut
|
||||||
?: ?=(%help -.q.p.sut) `crib.p.q.p.sut ~
|
?: ?=(%help -.q.p.sut) `crib.p.q.p.sut ~
|
||||||
==
|
==
|
||||||
|
:> gets the $help from a %help %hint type and returns it as a unit
|
||||||
|
++ help-from-hint
|
||||||
|
|= sut=type
|
||||||
|
^- (unit help)
|
||||||
|
?+ sut ~
|
||||||
|
[%hold *]
|
||||||
|
~? >> debug %help-from-hold $(sut (~(play ut p.sut) q.sut))
|
||||||
|
::
|
||||||
|
[%hint *]
|
||||||
|
~? >> debug %help-from-hint
|
||||||
|
?. ?=(%help -.q.p.sut)
|
||||||
|
~
|
||||||
|
(some p.q.p.sut)
|
||||||
|
==
|
||||||
::
|
::
|
||||||
:> returns 0, 1, or 2 whats for an arm
|
:> returns 0, 1, or 2 whats for an arm
|
||||||
|
:>
|
||||||
|
:> this arm should be handed the compiled type of the hoon of an arm, as well
|
||||||
|
:> as the name of that arm. it checks for up to 2 nested hints on the outermost
|
||||||
|
:> layer of the type. if you have 2, it is presumed to be arm-doc followed by
|
||||||
|
:> product-doc. if you only have one, we check links in the $help of the hint
|
||||||
|
:> to determine whether it is an arm doc or product doc.
|
||||||
|
:>
|
||||||
|
:> this returns ~ if there are no docs. if there are docs, the first one is the
|
||||||
|
:> arm-doc, and the second one is the product-doc.
|
||||||
++ arm-product-docs
|
++ arm-product-docs
|
||||||
|= [sut=type name=tape]
|
|= [sut=type name=term]
|
||||||
^- (unit [what what])
|
^- (unit [what what])
|
||||||
=/ doc-one=(unit help)
|
=/ doc-one=(unit help)
|
||||||
?: ?=([%hint [* [%help ^]] *] sut)
|
(help-from-hint sut)
|
||||||
`p.q.p.sut
|
|
||||||
~
|
|
||||||
?~ doc-one
|
?~ doc-one
|
||||||
:: no need to look for a second doc if there is no first one
|
~? > debug %doc-one-empty
|
||||||
~
|
~ :: no need to look for a second doc if there is no first one
|
||||||
|
:: technically doc-two doesn't need to be a help, i could just grab the what
|
||||||
|
:: directly since we aren't testing it to see if its an arm-doc, but it makes
|
||||||
|
:: the code more confusing to use a different structure.
|
||||||
=/ doc-two=(unit help)
|
=/ doc-two=(unit help)
|
||||||
?> ?=([%hint *] sut)
|
?> ?=([%hint *] sut)
|
||||||
?: ?=([%hint [* [%help ^]] *] q.sut)
|
(help-from-hint q.sut)
|
||||||
`p.q.p.q.sut
|
|
||||||
~
|
|
||||||
?~ doc-two
|
?~ doc-two
|
||||||
|
~? > debug %doc-two-empty
|
||||||
?~ links.u.doc-one
|
?~ links.u.doc-one
|
||||||
:: if links are empty, doc-one is a product-doc
|
:: if links are empty, doc-one is a product-doc
|
||||||
[~ [~ `crib.u.doc-one]]
|
[~ [~ (some crib.u.doc-one)]]
|
||||||
?: =([%funk `@tas`(crip name)] i.links.u.doc-one)
|
?: =([%funk name] i.links.u.doc-one)
|
||||||
:: if links are non-empty, check that the link is for the arm
|
:: if links are non-empty, check that the link is for the arm
|
||||||
[~ [`crib.u.doc-one ~]]
|
~? > debug %link-match
|
||||||
|
[~ [(some crib.u.doc-one) ~]]
|
||||||
~? > debug %link-doesnt-match-arm
|
~? > debug %link-doesnt-match-arm
|
||||||
:: this shouldn't happen at this point in time
|
:: this shouldn't happen at this point in time
|
||||||
[~ [`crib.u.doc-one ~]]
|
[~ [(some crib.u.doc-one) ~]]
|
||||||
:: doc-two is non-empty. make sure that doc-one is an arm-doc
|
:: doc-two is non-empty. make sure that doc-one is an arm-doc
|
||||||
?~ links.u.doc-one
|
?~ links.u.doc-one
|
||||||
~? > debug %doc-one-empty-link
|
~? > debug %doc-one-empty-link
|
||||||
[~ [`crib.u.doc-one `crib.u.doc-two]]
|
[~ [(some crib.u.doc-one) (some crib.u.doc-two)]]
|
||||||
[~ [`crib.u.doc-one `crib.u.doc-two]]
|
[~ [(some crib.u.doc-one) (some crib.u.doc-two)]]
|
||||||
::
|
::
|
||||||
:> grabs the docs for an arm.
|
:> grabs the docs for an arm.
|
||||||
:>
|
:>
|
||||||
@ -313,38 +333,42 @@
|
|||||||
:> docs for the arm itself, docs for the product of the arm, and
|
:> 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.
|
:> if the arm builds a core, docs for the default arm of that core.
|
||||||
:>
|
:>
|
||||||
:> arm-doc: docs wrapping the arm
|
:> arm-doc: docs written above the the arm
|
||||||
:> product-doc: docs for the product of the arm
|
:> product-doc: docs for the product of the arm
|
||||||
:> core-doc: docs for the default arm of the core produced by the arm
|
:> core-doc: docs for the default arm of the core produced by the arm
|
||||||
++ select-arm-docs
|
++ all-arm-docs
|
||||||
|= [gen=hoon sut=type name=tape]
|
|= [gen=hoon sut=type name=tape]
|
||||||
~? > debug %select-arm-docs
|
~? > debug %all-arm-docs
|
||||||
^- [what what what]
|
^- [what what what]
|
||||||
=+ hoon-type=(~(play ut sut) gen)
|
=+ hoon-type=(~(play ut sut) gen)
|
||||||
=+ arm-prod=(arm-product-docs hoon-type name)
|
=+ arm-prod=(arm-product-docs hoon-type `@tas`(crip name))
|
||||||
~? >> debug arm-prod
|
~? >> debug arm-prod
|
||||||
|^
|
|^
|
||||||
:: check arm-prod to determine how many layers to look into the type
|
:: check arm-prod to determine how many layers to look into the type
|
||||||
:: for core docs
|
:: for core docs
|
||||||
=/ depth=@ ?~ arm-prod 0
|
=/ depth=@ ?~ arm-prod 0
|
||||||
(add =(~ +<.arm-prod) =(~ +>.arm-prod))
|
(add =(~ +<.arm-prod) =(~ +>.arm-prod))
|
||||||
?+ depth [~ ~ ~]
|
?+ depth ``~
|
||||||
%0 [~ ~ (check-core hoon-type)]
|
%0 ``(extract hoon-type)
|
||||||
%1 :+ +<.arm-prod
|
%1 :+ +<.arm-prod
|
||||||
+>.arm-prod
|
+>.arm-prod
|
||||||
?> ?=([%hint *] hoon-type)
|
?> ?=([%hint *] hoon-type)
|
||||||
(check-core q.hoon-type)
|
(extract q.hoon-type)
|
||||||
%2 :+ +<.arm-prod
|
%2 :+ +<.arm-prod
|
||||||
+>.arm-prod
|
+>.arm-prod
|
||||||
?> ?=([%hint *] hoon-type)
|
?> ?=([%hint *] hoon-type)
|
||||||
?> ?=([%hint *] q.hoon-type)
|
?> ?=([%hint *] q.hoon-type)
|
||||||
(check-core q.q.hoon-type)
|
(extract q.q.hoon-type)
|
||||||
==
|
==
|
||||||
++ check-core
|
:> grabs the first doc for the default arm of a core
|
||||||
|
:>
|
||||||
|
:> this could end up being an arm doc or a product doc. or it might even
|
||||||
|
:> produce another core with docs in that. should I care?
|
||||||
|
++ extract
|
||||||
|= sut=type
|
|= sut=type
|
||||||
^- what
|
^- what
|
||||||
?: ?=([%core *] sut)
|
?: ?=([%core *] sut)
|
||||||
(what-from-type (~(play ut sut) [%limb %$]))
|
(what-from-hint (~(play ut sut) [%limb %$]))
|
||||||
~
|
~
|
||||||
--
|
--
|
||||||
::
|
::
|
||||||
@ -402,7 +426,7 @@
|
|||||||
^- overview
|
^- overview
|
||||||
%+ turn ~(tap by a)
|
%+ turn ~(tap by a)
|
||||||
|= ar=(pair term hoon)
|
|= ar=(pair term hoon)
|
||||||
=+ [adoc pdoc cdoc]=(select-arm-docs q.ar sut (trip p.ar))
|
=+ [adoc pdoc cdoc]=(all-arm-docs q.ar sut (trip p.ar))
|
||||||
[%item (weld "++" (trip p.ar)) adoc]
|
[%item (weld "++" (trip p.ar)) adoc]
|
||||||
::
|
::
|
||||||
:> changes an item into an overview
|
:> changes an item into an overview
|
||||||
@ -440,10 +464,7 @@
|
|||||||
?~ lhs rhs
|
?~ lhs rhs
|
||||||
?~ rhs lhs
|
?~ rhs lhs
|
||||||
`[%view (weld (item-as-overview lhs) (item-as-overview rhs))]
|
`[%view (weld (item-as-overview lhs) (item-as-overview rhs))]
|
||||||
:: :> #
|
::
|
||||||
:: :> # %printing
|
|
||||||
:: :> #
|
|
||||||
:: :> functions which display output of various types
|
|
||||||
+| %printing
|
+| %printing
|
||||||
:> prints a doccords item
|
:> prints a doccords item
|
||||||
++ print-item
|
++ print-item
|
||||||
@ -501,13 +522,13 @@
|
|||||||
|= [name=tape docs=what gen=hoon sut=type]
|
|= [name=tape docs=what gen=hoon sut=type]
|
||||||
^- tang
|
^- tang
|
||||||
~? >> debug %print-arm
|
~? >> debug %print-arm
|
||||||
=+ [main-doc product-doc core-doc]=(select-arm-docs gen sut name)
|
=+ [adoc pdoc cdoc]=(all-arm-docs gen sut name)
|
||||||
;: weld
|
;: weld
|
||||||
(print-header name main-doc)
|
(print-header name adoc)
|
||||||
`tang`[[%leaf ""] [%leaf "product:"] ~]
|
`tang`[[%leaf ""] [%leaf "product:"] ~]
|
||||||
(print-header "" product-doc)
|
(print-header "" pdoc)
|
||||||
`tang`[[%leaf ""] [%leaf "default arm in core:"] ~]
|
`tang`[[%leaf ""] [%leaf "default arm in core:"] ~]
|
||||||
(print-header "" core-doc)
|
(print-header "" cdoc)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
:> renders documentation for a face
|
:> renders documentation for a face
|
||||||
|
Loading…
Reference in New Issue
Block a user