diff options
| author | Albert Krewinkel <[email protected]> | 2023-03-19 13:02:36 +0100 |
|---|---|---|
| committer | Albert Krewinkel <[email protected]> | 2023-03-19 13:35:02 +0100 |
| commit | 07c56322c24062082b798961573f0dbb22c4937b (patch) | |
| tree | 549804e1ea1a4d93a9e364e640d70cc3d45cd601 /tools | |
| parent | ec1a06f5effcf57c6c8d1bd30c47e316a2f13206 (diff) | |
lua-filters.md: generate docs from Haskell for pandoc.structure
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/update-lua-module-docs.lua | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/tools/update-lua-module-docs.lua b/tools/update-lua-module-docs.lua index f8531b5c5..7ea6de3f6 100644 --- a/tools/update-lua-module-docs.lua +++ b/tools/update-lua-module-docs.lua @@ -37,14 +37,20 @@ local get = function (fieldname) end local function read_blocks (txt) - return read(txt, 'commonmark+smart').blocks + return read(txt, 'commonmark+smart+wikilinks_title_before_pipe').blocks end local function read_inlines (txt) return utils.blocks_to_inlines(read_blocks(txt)) end -local known_types = {} +local known_types = { + Block = 'type-block', + Blocks = 'type-blocks', + ChunkedDoc = 'type-chunkeddoc', + Pandoc = 'type-pandoc', + WriterOptions = 'type-writeroptions', +} local function render_typespec (typespec) if typespec.basic then @@ -136,11 +142,11 @@ local function render_function (doc, level, modulename) List(doc.parameters):map( function (p) return { - {Code(p.name)}, - append_inlines( + Inlines{Code(p.name)}, + {append_inlines( read_blocks(p.description), type_to_inlines(p.type) - ) + )} } end ) @@ -297,6 +303,17 @@ end function _G.Reader (inputs, opts) local blocks = foo(tostring(inputs), Blocks{}, 1) blocks = blocks:walk { + Link = function (link) + if link.title == 'wikilink' then + link.title = '' + if known_types[link.target] then + link.target = '#' .. known_types[link.target] + else + warn('Unknown type: ' .. link.target) + end + return link + end + end, Span = function (span) local unknown_type = span.attributes['unknown-type'] if unknown_type and known_types[unknown_type] then @@ -304,7 +321,7 @@ function _G.Reader (inputs, opts) elseif span.classes:includes 'builtin-lua-type' then return span.content -- unwrap end - end + end, } return Pandoc(blocks) end |
