Skip to content

Commit

Permalink
added recursive list search for headings
Browse files Browse the repository at this point in the history
  • Loading branch information
0815Creeper committed Oct 27, 2023
1 parent 6052e5f commit d25c548
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/expander_pipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -961,12 +961,13 @@ function create_docsnode(docstrings, results, object, page, doc)
slug = Documenter.slugify(object)
anchor = Documenter.anchor_add!(doc.internal.docs, object, slug, page.build)
docsnode = DocsNode(anchor, object, page)
# Convert docstring to MarkdownAST, convert Heading elements, and push to DocsNode
for (markdown, result) in zip(docstrings, results)
ast = convert(Node, markdown)
doc.user.highlightsig && highlightsig!(ast)
# The following 'for' corresponds to the old dropheaders() function
function recursive_heading_to_bold!(ast)

Check warning on line 964 in src/expander_pipeline.jl

View check run for this annotation

Codecov / codecov/patch

src/expander_pipeline.jl#L964

Added line #L964 was not covered by tests
for headingnode in ast.children
if headingnode.element isa MarkdownAST.List
for child in headingnode.children
recursive_heading_to_bold!(child)
end

Check warning on line 969 in src/expander_pipeline.jl

View check run for this annotation

Codecov / codecov/patch

src/expander_pipeline.jl#L966-L969

Added lines #L966 - L969 were not covered by tests
end
headingnode.element isa MarkdownAST.Heading || continue
boldnode = Node(MarkdownAST.Strong())
for textnode in collect(headingnode.children)
Expand All @@ -975,6 +976,12 @@ function create_docsnode(docstrings, results, object, page, doc)
headingnode.element = MarkdownAST.Paragraph()
push!(headingnode.children, boldnode)
end
end
# Convert docstring to MarkdownAST, convert Heading elements, and push to DocsNode
for (markdown, result) in zip(docstrings, results)
ast = convert(Node, markdown)
doc.user.highlightsig && highlightsig!(ast)
recursive_heading_to_bold!(ast)

Check warning on line 984 in src/expander_pipeline.jl

View check run for this annotation

Codecov / codecov/patch

src/expander_pipeline.jl#L981-L984

Added lines #L981 - L984 were not covered by tests
push!(docsnode.mdasts, ast)
push!(docsnode.results, result)
push!(docsnode.metas, markdown.meta)
Expand Down

0 comments on commit d25c548

Please sign in to comment.