refactor: hyperlink more notations such as field notations #261
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current DocGen hyperlink system is as following:
CodeWithInfos
is text sent to the infoview to display terms with additional datas when hovered.For example, let's see what
CodeWithInfos
sent to the infoview when it displayList.insert 0 [1, 2]
.prettyPrintTerm
does the same process when display terms on the infoview, but DocGen runsprettyPrintTerm
withset_option pp.tagAppFns true
; this option makes constant application tagged with its constant. So, in the last example,#[.text "List.insert", ..]
becomes#[L.tag { info := ⟨{ info := { expr := (q(@List.insert) : Expr), .. }, .. }⟩, .. } (.text "List.insert"), .text " ", ..]
.Then,
docInfoToHtml
hyperlinks text tagged with constants.However, current DocGen doesn't hyperlink field notations;
.Nodup
in[0, 1, 2].Nodup
isn't hyperlinked toList.Nodup
, this is becausepp.tagAppFns
doesn't tag field notations.This problem comes from the limitation of
pp.tagAppFns
, so the solution is refactoringpp.tagAppFns
to tag field notations, or refactoringdocInfoToHtml
to hyperlink terms without relying onpp.tagAppFns
, so I chose the latter solution.The new
docInfoToHtml
hyperlinksCodeWithInfos
without constant tags, ifdecInfoToHtml
find a constant application tag, then it checks whether all tags of explicit arguments of the tag appear in direct children. If so, it hyperlinks non-tagged text in direct children.It hyperlinks more notations such as field notations.
As a special case, when
fun x => t(x)
appears as a explicit argument,docInfoToHtml
allows to appeart(x)
instead offun x => t(x)
, to hyperlink binder notations like{ s : String // 0 < s.length }
.⚠ Improvement points
Sometimes, parenthesis maybe hyperlinked. This is because
docInfoToHtml
hyperlinks text according to info.resolves #91, resolves #224