Skip to content

Commit

Permalink
Merge pull request #181 from LuxDL/ap/collapse
Browse files Browse the repository at this point in the history
feat: minor improvements to the new docstring blocks
  • Loading branch information
avik-pal authored Sep 21, 2024
2 parents 763aa13 + 8b39396 commit 865cd35
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 4 deletions.
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 <lazarus.alon@gmail.com>", "Anshul Singhvi <as6208@columbia.edu>"]
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
17 changes: 17 additions & 0 deletions docs/src/code_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,20 @@ 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`. Example usage:
**Input**
````
```@meta
CollapsedDocStrings = true
```
````
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 @@ end

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"
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

2 comments on commit 865cd35

@avik-pal
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/115616

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.3 -m "<description of version>" 865cd3565bf433ec087d9646f2b137833a0b08e4
git push origin v0.1.3

Please sign in to comment.