API reference

This is the offical API reference of DocExtensions. Note that it can also be queried interactively from the Julia REPL using the help mode:

julia> using DocExtensions
julia>?
help?> DocExtensions

Extensions to Markdown

DocExtensions.MarkdownExtensionsModule

Module MarkdownExtensions

Provides extensions to Markdown (in particular features that are only available in particular Markdown flavors).

Index

Documentation

DocExtensions.MarkdownExtensions.expand_reflinksMethod
expand_reflinks(reflinks; filepattern=".MD", outfilepattern=".md", rootdir=".")

Expand the reference links reflinks in the file or collection of files in directory rootdir defined by filepattern, writing the result back to the file(s) specified with outfilepattern; for both filepattern and outfilepattern currently supported is a file name extension (e.g. filepattern = ".MD" and outfilepattern = ".md") or simply an explicit file name. Currently, only reference links of the form "[refstring]" are supported, not those of the form "[...][refstring]".

Arguments

  • reflinks::Dict{<:AbstractString, <:AbstractString}: the reference links to be expanded.

Keyword Arguments

  • filepattern::AbstractString=".MD": a file extension or file name defining the files to be processed.
  • outfilepattern::AbstractString=lowercase(filepattern): a file extension or file name defining the name(s) of the output files.
  • rootdir::AbstractString=".": the root directory of the files to be processed.

Extensions to Documenter.jl

Index

Documentation

DocExtensions.DocumenterExtensions.mdincludeMethod
mdinclude(path)

Include a file as markdown content. Files with a ".jl"-extension are included as a Julia code block; files with any other extension are parsed as markdown.

Example

Main.mdinclude(joinpath(Main.EXAMPLEROOT, "example.jl"))

Simple generic file processor

Index

Documentation

DocExtensions.FileProcessor.mapMethod
map(filepattern, f, args...; outfilepattern=filepattern, rootdir=".")
map(filepattern, (f, args)...; outfilepattern=filepattern, rootdir=".")

Transform the file or collection of files in directory rootdir defined by filepattern by applying f to content of each file (calling f(content, args...)), writing the result back to the file(s) specified with outfilepattern. The results of the file content transformation is also returned as a Vector of Strings. To apply multiple functions to the content of each file, a series of tuples of the kind (f, args...) can be passed instead of f, args....

Arguments

  • f::Function: the function to be applied to the content of the files.
  • `filepattern::AbstractString: a file extension or file name defining the files to be processed.
  • args...: arguments to be passed to f in addition to the content of each file.

Keyword Arguments

  • outfilepattern::AbstractString=filepattern: a file extension or file name defining the name(s) of the output files.
  • rootdir::AbstractString=".": the root directory of the files to be processed.
  • do_write::Bool=true:: whether to actually write the results into file(s).

Example

docsrc             = joinpath(@__DIR__, "src")
file_extension     = ".MD"
new_file_extension = ".md"
reflinks           = Dict("[Adapt.jl]"        => "https://github.com/JuliaGPU/Adapt.jl",
                          "[AMDGPU.jl]"       => "https://github.com/JuliaGPU/AMDGPU.jl",
                          "[CellArrays.jl]"   => "https://github.com/omlins/CellArrays.jl",
                          "[CUDA.jl]"         => "https://github.com/JuliaGPU/CUDA.jl",
                          "[StaticArrays.jl]" => "https://github.com/JuliaArrays/StaticArrays.jl",
)

escape(s)      = "\Q" * escape_string(s) * "\E"
pattern        = Regex("(" * join(escape.(keys(reflinks)), "|") * ")(?![(].*[)])")
replace_str(x) = "$x($(reflinks[x]))"

FileProcessor.map(file_extension, replace, pattern => replace_str; outfilepattern=new_file_extension, rootdir="src")