1
0
mirror of https://github.com/janet-lang/janet synced 2024-09-28 07:08:14 +00:00

Add anchors in generated docs

This allows us to link to specific functions.
This commit is contained in:
Calvin Rose 2019-01-26 10:12:33 -05:00
parent e755f98300
commit 7350bf5dd9

View File

@ -75,6 +75,7 @@
:ref ref :ref ref
:source-map sm :source-map sm
:doc docstring} env-entry :doc docstring} env-entry
html-key (html-escape key)
binding-type (cond binding-type (cond
macro :macro macro :macro
ref (string :var " (" (type (get ref 0)) ")") ref (string :var " (" (type (get ref 0)) ")")
@ -82,7 +83,7 @@
source-ref (if-let [[path start end] sm] source-ref (if-let [[path start end] sm]
(string "<span class=\"source-map\">" path " (" start ":" end ")</span>") (string "<span class=\"source-map\">" path " (" start ":" end ")</span>")
"")] "")]
(string "<h2 class=\"binding\">" (html-escape key) "</h2>\n" (string "<h2 class=\"binding\"><a id=\"" key "\">" html-key "</a></h2>\n"
"<span class=\"binding-type\">" binding-type "</span>\n" "<span class=\"binding-type\">" binding-type "</span>\n"
"<p class=\"docstring\">" (trim-lead (html-escape docstring)) "</p>\n" "<p class=\"docstring\">" (trim-lead (html-escape docstring)) "</p>\n"
source-ref))) source-ref)))