From 39f34940e503777787b8c8d9bff6664095848405 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Thu, 19 Sep 2024 19:07:27 -0400 Subject: [PATCH 1/5] fix: make the headers looks similar to Documenter --- Project.toml | 2 +- src/writer.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index eeff70c..0394197 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "DocumenterVitepress" uuid = "4710194d-e776-4893-9690-8d956a29c365" authors = ["Lazaro Alonso ", "Anshul Singhvi "] -version = "0.1.2" +version = "0.1.3" [deps] ANSIColoredPrinters = "a4c015fc-c6ff-483c-b24f-f7ea428134e9" diff --git a/src/writer.jl b/src/writer.jl index 4397428..91b1dd1 100644 --- a/src/writer.jl +++ b/src/writer.jl @@ -317,7 +317,7 @@ function render(io::IO, mime::MIME"text/plain", node::Documenter.MarkdownAST.Nod # Docstring header based on the name of the binding and it's category. _badge_text = """""" print(io ,"""
- # $(docs.object.binding) $(_badge_text)\n + $(docs.object.binding) $(_badge_text)\n """) # Body. May contain several concatenated docstrings. renderdoc(io, mime, node, page, doc; kwargs...) From 6226067505317ec61407624dc21d69fe5e2d7eb9 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Thu, 19 Sep 2024 19:43:39 -0400 Subject: [PATCH 2/5] feat: support CollapsedDocStrings meta --- docs/src/api.md | 5 ++++- src/writer.jl | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/src/api.md b/docs/src/api.md index 8d2efd9..1b4bd0b 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -5,8 +5,11 @@ outline: deep ``` ## Public API + ```@meta -DocTestSetup= quote +CollapsedDocStrings = true + +DocTestSetup = quote using DocumenterVitepress end ``` diff --git a/src/writer.jl b/src/writer.jl index 91b1dd1..4d29a36 100644 --- a/src/writer.jl +++ b/src/writer.jl @@ -313,10 +313,11 @@ 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 = """""" - print(io ,"""
+ print(io ,"""
$(docs.object.binding) $(_badge_text)\n """) # Body. May contain several concatenated docstrings. From 3ee3004877c00b5d663a9fc3836756b6e5e5d6ea Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Fri, 20 Sep 2024 10:15:45 -0400 Subject: [PATCH 3/5] docs: add internal docs using collapsed docstrings --- docs/make.jl | 1 + docs/src/api.md | 2 -- docs/src/internal_api.md | 22 ++++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 docs/src/internal_api.md diff --git a/docs/make.jl b/docs/make.jl index efb8bea..147e875 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -53,6 +53,7 @@ makedocs(; ], "Developers' documentation" => [ "The rendering process" => "render_pipeline.md", + "Internal API" => "internal_api.md", ], "api.md", ], diff --git a/docs/src/api.md b/docs/src/api.md index 1b4bd0b..6d33a26 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -7,8 +7,6 @@ outline: deep ## Public API ```@meta -CollapsedDocStrings = true - DocTestSetup = quote using DocumenterVitepress end diff --git a/docs/src/internal_api.md b/docs/src/internal_api.md new file mode 100644 index 0000000..28db2ff --- /dev/null +++ b/docs/src/internal_api.md @@ -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 +``` From 259825b3956dec12388ba63fd593351c6fce8b79 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Fri, 20 Sep 2024 10:19:58 -0400 Subject: [PATCH 4/5] docs: document the meta tag --- docs/src/code_example.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/src/code_example.md b/docs/src/code_example.md index 171416c..89e11d0 100644 --- a/docs/src/code_example.md +++ b/docs/src/code_example.md @@ -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`. From 8b39396a9ba94ca1f0664b9cdd2829d20ea4afaf Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Fri, 20 Sep 2024 15:53:38 -0400 Subject: [PATCH 5/5] docs: add the code to the docs --- docs/src/code_example.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/src/code_example.md b/docs/src/code_example.md index 89e11d0..a150e37 100644 --- a/docs/src/code_example.md +++ b/docs/src/code_example.md @@ -207,4 +207,12 @@ 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`. + is set to `true`. Example usage: + +**Input** + +```` +```@meta +CollapsedDocStrings = true +``` +````