-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve cross-linking of types in 'Pandoc Lua Filters' docs #10529
Comments
@tarleb what do you think? |
This is a good idea, but we would have to update HsLua and the |
Linking for reference:
I don't know enough about the specifics of this currently; but my original naive thought/notice was that for the ones I checked, the URL hash needed to link between them was basically something like Which looks like at least half of which already exists in pandoc/tools/update-lua-module-docs.lua Lines 75 to 105 in 58ca8df
Exploring deeper with GitHub Copilot
References:
This is the diff of the changes it suggested making to implement this. I haven't sought to verify them, but wanted to include them here for completeness in case they are helpful: --- Unsaved view (768)
+++ Unsaved view (770)
@@ -217,6 +217,7 @@
end
)
)
+ local crosslink = known_types[modulename] and Para{Str("Values of this type can be created with the "), Link(modulename, '#' .. modulename), Str(" constructor.")} or Blocks{}
return Blocks{
Header(level, name, {id}),
Plain{Code(string.format('%s (%s)', name, args))},
@@ -226,6 +227,7 @@
.. List(#doc.results > 0 and {Para 'Returns:'} or {})
.. render_results(doc.results)
.. Blocks(doc.since and {Para{Emph{'Since: ' .. doc.since}}} or {})
+ .. crosslink
end
--- Renders documentation of a module field.
@@ -295,8 +297,10 @@
end
local header_id = 'type-' .. nameprefix .. '.' .. name
known_types[name] = known_types[name] or header_id
+ local crosslink = known_types[name] and Para{Str("This constructor creates values of type "), Link(name, '#' .. name), Str(".")} or Blocks{}
return {Header(level, name, {header_id})} ..
- type_description
+ type_description ..
+ crosslink
end
--- Renders module documentation. The 1st/2nd diff blocks are in |
In the spirit of:
Describe your proposed improvement and the problem it solves.
In the Lua Filters documentation, there are generally 2 different sections for the various types, and their constructors. eg.
Emph
(type)`: https://pandoc.org/lua-filters.html#type-emphEmph
(contructor): https://pandoc.org/lua-filters.html#pandoc.EmphCodeBlock
(type): https://pandoc.org/lua-filters.html#type-codeblockCodeBlock
(constructor): https://pandoc.org/lua-filters.html#pandoc.CodeBlockA pattern I've noticed is that the 'type' usually includes a cross-link to the 'constructor':
But the 'constructor' doesn't seem to include a crosslink to the 'type', and usually only refers to the more generic
Block
/Inline
:While I was recently exploring writing a lua filter I found myself spending a lot of time jumping back and forth in the docs, and felt like it would be easier if those sections cross-linked to one another.
Describe alternatives you've considered.
I'm aware of this issue/PR, but the nuance is different:
This docs issue is also unrelated, except for improving the docs UX for new users in general:
pandoc.scaffolding
section in 'Pandoc Lua Filters' docs (RE: Custom Writers) #10531The text was updated successfully, but these errors were encountered: