Internals
These functions, types etc. are internal to DocStringExtensions and not part of the public API. They may change or be removed arbitrarily from version to version.
DocStringExtensions.Abbreviation
DocStringExtensions.DocStringTemplate
DocStringExtensions.FunctionName
DocStringExtensions.License
DocStringExtensions.MethodList
DocStringExtensions.MethodSignatures
DocStringExtensions.ModuleExports
DocStringExtensions.ModuleImports
DocStringExtensions.Readme
DocStringExtensions.Template
DocStringExtensions.TypeDefinition
DocStringExtensions.TypeFields
DocStringExtensions.TypedMethodSignatures
DocStringExtensions.alltypesigs
DocStringExtensions.arguments
DocStringExtensions.cleanpath
DocStringExtensions.comparemethods
DocStringExtensions.find_tuples
DocStringExtensions.format
DocStringExtensions.getmethods
DocStringExtensions.getmethods!
DocStringExtensions.groupby
DocStringExtensions.groupby!
DocStringExtensions.hook!
DocStringExtensions.hook!
DocStringExtensions.interpolation
DocStringExtensions.keywords
DocStringExtensions.method_length_over_limit
DocStringExtensions.methodgroups
DocStringExtensions.parsedocs
DocStringExtensions.printmethod
DocStringExtensions.printmethod
DocStringExtensions.url
DocStringExtensions.alltypesigs
— Methodalltypesigs(sig)
Returns a Vector
of the Tuple
types contained in sig
.
DocStringExtensions.arguments
— Methodarguments(m)
Returns the list of arguments for a particular method m
.
Examples
f(x; a = 1, b...) = x
args = arguments(first(methods(f)))
DocStringExtensions.cleanpath
— Methodcleanpath(path)
Remove the Pkg.dir
part of a file path
if it exists.
DocStringExtensions.comparemethods
— Methodcomparemethods(a, b)
Compare methods a
and b
by file and line number.
DocStringExtensions.find_tuples
— Methodfind_tuples(typesig)
Converts a method signature (or a union of several signatures) in a vector of (single) signatures.
This is used for decoding the method signature that a docstring is paired with. In the case when the docstring applies to multiple methods (e.g. when default positional argument values are used and define multiple methods at once), they are combined together as union of Tuple
types.
julia> DocStringExtensions.find_tuples(Tuple{String,Number,Int})
1-element Array{DataType,1}:
Tuple{String,Number,Int64}
julia> DocStringExtensions.find_tuples(Tuple{T} where T <: Integer)
1-element Array{DataType,1}:
Tuple{T<:Integer}
julia> s = Union{
Tuple{Int64},
Tuple{U},
Tuple{T},
Tuple{Int64,T},
Tuple{Int64,T,U}
} where U where T;
julia> DocStringExtensions.find_tuples(s)
5-element Array{DataType,1}:
Tuple{Int64}
Tuple{U}
Tuple{T}
Tuple{Int64,T}
Tuple{Int64,T,U}
DocStringExtensions.format
— Methodformat(abbr, buf, doc)
Expand the Abbreviation
abbr
in the context of the DocStr
doc
and write the resulting markdown-formatted text to the IOBuffer
buf
.
DocStringExtensions.getmethods!
— Methodgetmethods!(results, f, sig)
A helper method for getmethods
that collects methods in results
.
DocStringExtensions.getmethods
— Methodgetmethods(f, sig)
Collect and return all methods of function f
matching signature sig
.
This is similar to methods(f, sig)
, but handles type signatures found in DocStr
objects more consistently that methods
.
DocStringExtensions.groupby!
— Methodgroupby!(f, groups, data)
A helper method for groupby
that uses a pre-allocated groups
Dict
.
DocStringExtensions.groupby
— Methodgroupby(f, K, V, data)
Group data
using function f
where key type is specified by K
and group type by V
.
The function f
takes a single argument, an element of data
, and should return a 2-tuple of (computed_key, element)
. See the example below for details.
Examples
groupby(Int, Vector{Int}, collect(1:10)) do num
mod(num, 3), num
end
DocStringExtensions.hook!
— Methodhook!(func)
Set the docstring expander function to first call func
before calling the default expander.
To remove a hook that has been applied using this method call hook!()
.
DocStringExtensions.hook!
— Methodhook!()
Reset the docstring expander to only call the default expander function. This clears any 'hook' that has been set using hook!(func)
.
DocStringExtensions.interpolation
— Methodinterpolation(object::T, captured::Expr) -> new_object
Interface method for hooking into interpolation within docstrings to change the behaviour of the interpolation. object
is the interpolated object within a docstring and captured
is the raw expression that is documented by the docstring in which the interpolated object
has been included.
To define custom behaviour for your own object
types implement a method of interpolation(::T, captured)
for type T
and return a new_object
to be interpolated into the final docstring. Note that you must own the definition of type T
. new_object
does not need to be of type T
.
DocStringExtensions.keywords
— Methodkeywords(func, m)
Returns the list of keywords for a particular method m
of a function func
.
Examples
f(x; a = 1, b...) = x
kws = keywords(f, first(methods(f)))
DocStringExtensions.method_length_over_limit
— Methodmethod_length_over_limit(len)
Decides whether a length of method is too big to be visually appealing.
DocStringExtensions.methodgroups
— Methodmethodgroups(func, typesig, modname; exact)
Group all methods of function func
with type signatures typesig
in module modname
. Keyword argument exact = true
matches signatures "exactly" with ==
rather than <:
.
Examples
groups = methodgroups(f, Union{Tuple{Any}, Tuple{Any, Integer}}, Main; exact = false)
DocStringExtensions.parsedocs
— Methodparsedocs(mod)
Parse all docstrings defined within a module mod
.
DocStringExtensions.printmethod
— Methodprintmethod(
buffer::IOBuffer,
binding::Base.Docs.Binding,
func,
method::Method,
typesig
) -> IOBuffer
Print a simplified representation of a method signature to buffer
. Some of these simplifications include:
- no
TypeVar
s; - no types;
- no keyword default values;
Examples
f(x::Int; a = 1, b...) = x
sig = printmethod(Docs.Binding(Main, :f), f, first(methods(f)))
DocStringExtensions.printmethod
— Methodprintmethod(buffer, binding, func, method)
Print a simplified representation of a method signature to buffer
. Some of these simplifications include:
- no
TypeVar
s; - no types;
- no keyword default values;
_
printed where#unused#
arguments are found.
Examples
f(x; a = 1, b...) = x
sig = printmethod(Docs.Binding(Main, :f), f, first(methods(f)))
DocStringExtensions.url
— Methodurl(m)
Get the URL (file and line number) where a method m
is defined.
Note that this is based on the implementation of Base.url
, but handles URLs correctly on TravisCI as well.
DocStringExtensions.Abbreviation
— TypeAbbreviation objects are used to automatically generate context-dependent markdown content within documentation strings. Objects of this type interpolated into docstrings will be expanded automatically before parsing the text to markdown.
DocStringExtensions.DocStringTemplate
— TypeThe singleton type for DOCSTRING
abbreviations.
DocStringExtensions.FunctionName
— TypeThe singleton type for FUNCTIONNAME
abbreviations.
DocStringExtensions.License
— TypeThe singleton type for LICENSE
abbreviations.
DocStringExtensions.MethodList
— TypeThe singleton type for METHODLIST
abbreviations.
DocStringExtensions.MethodSignatures
— TypeThe singleton type for SIGNATURES
abbreviations.
DocStringExtensions.ModuleExports
— TypeThe singleton type for EXPORTS
abbreviations.
DocStringExtensions.ModuleImports
— TypeThe singleton type for IMPORTS
abbreviations.
DocStringExtensions.Readme
— TypeThe singleton type for README
abbreviations.
DocStringExtensions.Template
— TypeInternal abbreviation type used to wrap templated docstrings.
Location
is a Symbol
, either :before
or :after
. dict
stores a reference to a module's templates.
DocStringExtensions.TypeDefinition
— TypeThe singleton type for TYPEDEF
abbreviations.
DocStringExtensions.TypeFields
— TypeThe type for FIELDS
abbreviations.
types
DocStringExtensions.TypedMethodSignatures
— TypeThe singleton type for TYPEDSIGNATURES
abbreviations.