Skip to content

Commit

Permalink
Merge pull request #175 from tpoisot/master
Browse files Browse the repository at this point in the history
Use custom-block for docstrings
  • Loading branch information
lazarusA authored Sep 17, 2024
2 parents 4d92d21 + 4d51b0b commit e0099b5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
19 changes: 17 additions & 2 deletions docs/src/.vitepress/theme/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/var
*/
font-feature-settings: 'calt' 0;
pre {
font-family: JuliaMono-Light;
font-family: JuliaMono-Regular;
};
code {
font-family: JuliaMono-Light;
font-family: JuliaMono-Regular;
};
}

Expand Down Expand Up @@ -241,3 +241,18 @@ mjx-container > svg {
white-space: nowrap;
max-width: 200px;
} */


/* Component: Docstring Custom Block */

.jldocstring.custom-block {
border: 1px solid var(--vp-c-gray-2);
color: var(--vp-c-text-1)
}

.jldocstring.custom-block summary {
font-weight: 700;
cursor: pointer;
user-select: none;
margin: 0 0 8px;
}
10 changes: 4 additions & 6 deletions src/writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,12 @@ function render(io::IO, mime::MIME"text/plain", node::Documenter.MarkdownAST.Nod
# @infiltrate
anchor_id = Documenter.anchor_label(docs.anchor)
# Docstring header based on the name of the binding and it's category.
println(io,
"<div style='border-width:1px; border-style:solid; border-color:black; padding: 1em; border-radius: 25px;'>")
anchor = "<a id='$(anchor_id)' href='#$(anchor_id)'>#</a>"
header = "&nbsp;<b><u>$(docs.object.binding)</u></b> &mdash; <i>$(Documenter.doccat(docs.object))</i>."
println(io, anchor, header, "\n\n")
print(io ,"""<details class='jldocstring custom-block' open>
<summary><a id='$(anchor_id)' href='#$(anchor_id)'>#</a> <span class="jlbinding">$(docs.object.binding)</span> &mdash; <span class="jlobjecttype jl$(Documenter.doccat(docs.object))">$(Documenter.doccat(docs.object))</span></summary>\n
""")
# Body. May contain several concatenated docstrings.
renderdoc(io, mime, node, page, doc; kwargs...)
return println(io, "</div>\n<br>")
return println(io, "</details>\n")
end

function renderdoc(io::IO, mime::MIME"text/plain", node::Documenter.MarkdownAST.Node, page, doc; kwargs...)
Expand Down
19 changes: 17 additions & 2 deletions template/src/.vitepress/theme/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/var
*/
font-feature-settings: 'calt' 0;
pre {
font-family: JuliaMono-Light;
font-family: JuliaMono-Regular;
};
code {
font-family: JuliaMono-Light;
font-family: JuliaMono-Regular;
};
}

Expand Down Expand Up @@ -241,3 +241,18 @@ mjx-container > svg {
white-space: nowrap;
max-width: 200px;
} */


/* Component: Docstring Custom Block */

.jldocstring.custom-block {
border: 1px solid var(--vp-c-gray-2);
color: var(--vp-c-text-1)
}

.jldocstring.custom-block summary {
font-weight: 700;
cursor: pointer;
user-select: none;
margin: 0 0 8px;
}

2 comments on commit e0099b5

@avik-pal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lazarusA / @asinghvi17 should we release this? It is quite a significant visual improvement

@asinghvi17
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is this will break for users of custom CSS...we would need to manually inject the tag if it's not found.

Please sign in to comment.