Skip to content

Commit

Permalink
add docstrings to doc_str, MD and include in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mitiemann committed Jan 4, 2024
1 parent 4ace016 commit cd7b279
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions stdlib/Markdown/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ custom flavour of Markdown can be used, but this should generally be unnecessary
Markdown strings can be constructed using the string literal syntax `md"..."`.
## [API reference](@id stdlib-markdown-api)
```@docs
Markdown.MD
Markdown.@md_str
Markdown.@doc_str
```
10 changes: 10 additions & 0 deletions stdlib/Markdown/src/Markdown.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

"""
Markdown
Tools for working with the Markdown file format. Mainly for documentation.
The `Markdown` module provides the (internal) `MD` struct (type?) as well as the string
literals `md"..."` and `doc"..."`.
"""
module Markdown

Expand Down Expand Up @@ -63,6 +67,12 @@ function doc_str(md, source::LineNumberNode, mod::Module)
end
doc_str(md::AbstractString, source::LineNumberNode, mod::Module) = doc_str(parse(md), source, mod)

"""
macro doc_str(s)
Parse the given string as Markdown text, add line and module information and return a
corresponding `Markdown.MD` object.
"""
macro doc_str(s::AbstractString, t...)
docexpr(__source__, __module__, s, t...)
end
Expand Down
6 changes: 6 additions & 0 deletions stdlib/Markdown/src/parse/parse.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

"""
MD
`MD` represents a Markdown document. However, `MD` objects should only be constructed using
the exported macros `@md_str` and `@doc_str`.
"""
mutable struct MD
content::Vector{Any}
meta::Dict{Symbol, Any}
Expand Down

0 comments on commit cd7b279

Please sign in to comment.