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

feat: minor improvements to the new docstring blocks #181

Merged
merged 5 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DocumenterVitepress"
uuid = "4710194d-e776-4893-9690-8d956a29c365"
authors = ["Lazaro Alonso <[email protected]>", "Anshul Singhvi <[email protected]>"]
version = "0.1.2"
version = "0.1.3"

[deps]
ANSIColoredPrinters = "a4c015fc-c6ff-483c-b24f-f7ea428134e9"
Expand Down
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ makedocs(;
],
"Developers' documentation" => [
"The rendering process" => "render_pipeline.md",
"Internal API" => "internal_api.md",
],
"api.md",
],
Expand Down
3 changes: 2 additions & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ outline: deep
```

## Public API

```@meta
DocTestSetup= quote
DocTestSetup = quote
using DocumenterVitepress
end
```
Expand Down
9 changes: 9 additions & 0 deletions docs/src/code_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,12 @@ julia> 1 + 1
2

```

## @meta

Supported meta tags:

- `CollapsedDocStrings`: works similar to Documenter.jl. If provided, the docstrings in
that page will be collapsed by default. Defaults to `false`. See the
[Internal API](@ref internal_api) page for how the docstrings are displayed when this
is set to `true`.
lazarusA marked this conversation as resolved.
Show resolved Hide resolved
22 changes: 22 additions & 0 deletions docs/src/internal_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
```@raw html
---
outline: deep
---
```

## [Internal API](@id internal_api)

These functions are not part of the public API, and are subject to change without notice.

```@meta
CollapsedDocStrings = true
DocTestSetup = quote
using DocumenterVitepress
end
```

```@autodocs
Modules = [DocumenterVitepress]
Public = false
```
5 changes: 3 additions & 2 deletions src/writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,12 @@

function render(io::IO, mime::MIME"text/plain", node::Documenter.MarkdownAST.Node, docs::Documenter.DocsNode, page, doc; kwargs...)
# @infiltrate
open_txt = get(page.globals.meta, :CollapsedDocStrings, false) ? "" : "open"
lazarusA marked this conversation as resolved.
Show resolved Hide resolved
anchor_id = Documenter.anchor_label(docs.anchor)
# Docstring header based on the name of the binding and it's category.
_badge_text = """<Badge type="info" class="jlObjectType jl$(Documenter.doccat(docs.object))" text="$(Documenter.doccat(docs.object))" />"""
print(io ,"""<details class='jldocstring custom-block' open>
<summary><a id='$(anchor_id)' href='#$(anchor_id)'>#</a> <span class="jlbinding">$(docs.object.binding)</span> $(_badge_text)</summary>\n
print(io ,"""<details class='jldocstring custom-block' $(open_txt)>
<summary><a id='$(anchor_id)' href='#$(anchor_id)'><span class="jlbinding">$(docs.object.binding)</span></a> $(_badge_text)</summary>\n
""")
# Body. May contain several concatenated docstrings.
renderdoc(io, mime, node, page, doc; kwargs...)
Expand Down Expand Up @@ -698,7 +699,7 @@
# Code blocks
function render(io::IO, mime::MIME"text/plain", node::Documenter.MarkdownAST.Node, code::MarkdownAST.CodeBlock, page, doc; kwargs...)
if startswith(code.info, "@")
@warn """

Check warning on line 702 in src/writer.jl

View workflow job for this annotation

GitHub Actions / build

DocumenterVitepress: un-expanded `@doctest` block encountered on page src/code_example.md. The first few lines of code in this node are: ``` julia> 1 + 1 2 ```
DocumenterVitepress: un-expanded `$(code.info)` block encountered on page $(page.source).
The first few lines of code in this node are:
```
Expand Down
Loading