Skip to content
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

Use custom-block for docstrings #175

Merged
merged 23 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ makedocs(;
warnonly = true,
checkdocs=:all,
format=DocumenterVitepress.MarkdownVitepress(
repo = "github.com/LuxDL/DocumenterVitepress.jl", # this must be the full URL!
repo = "github.com/tpoisot/DocumenterVitepress.jl", # this must be the full URL!
devbranch = "master",
devurl = "dev";
),
Expand Down Expand Up @@ -61,7 +61,7 @@ makedocs(;


deploydocs(;
repo = "github.com/LuxDL/DocumenterVitepress.jl", # this must be the full URL!
repo = "github.com/tpoisot/DocumenterVitepress.jl", # this must be the full URL!
target = "build", # this is where Vitepress stores its output
branch = "gh-pages",
devbranch = "master",
Expand Down
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;
}