forked from JuliaStats/Distributions.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e29b555
commit b924862
Showing
47 changed files
with
1,947 additions
and
1,022 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
`genrst.jl` generates the rst files from Julia docstrings. This should be run *before* committing the changes to the repository. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Distributions | ||
|
||
if VERSION < v"0.5.0-" | ||
function Markdown.rstinline(io::IO, md::Markdown.Link) | ||
if ismatch(r":(func|obj|ref|exc|class|const|data):`\.*", md.url) | ||
Markdown.rstinline(io, md.url) | ||
else | ||
Markdown.rstinline(io, "`", md.text, " <", md.url, ">`_") | ||
end | ||
end | ||
end | ||
|
||
function printrst(io,md) | ||
mdd = md.content[1] | ||
sigs = shift!(mdd.content) | ||
|
||
decl = ".. function:: "*replace(sigs.code, "\n","\n ") | ||
body = Markdown.rst(mdd) | ||
println(io, decl) | ||
println(io) | ||
for l in split(body, "\n") | ||
ismatch(r"^\s*$", l) ? println(io) : println(io, " ", l) | ||
end | ||
end | ||
|
||
cd(joinpath(dirname(@__FILE__),"source")) do | ||
for (name,T) in [("Univariate Discrete",DiscreteUnivariateDistribution), | ||
("Univariate Continuous",ContinuousUnivariateDistribution), | ||
] | ||
|
||
fname = replace(lowercase(name),' ','-') | ||
open("$fname.rst","w") do f | ||
println(f,".. _$fname:") | ||
println(f) | ||
println(f,"$name Distributions") | ||
println(f,"----------------------------------------------------") | ||
println(f) | ||
println(f, ".. DO NOT EDIT: this file is generated from Julia source.") | ||
println(f) | ||
|
||
for D in subtypes(T) | ||
if isleaftype(D) | ||
md = Base.doc(D) | ||
if isa(md,Markdown.MD) | ||
isa(md.content[1].content[1],Markdown.Code) || error("Incorrect docstring format: $D") | ||
|
||
printrst(f,md) | ||
else | ||
warn("$D is not documented.") | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.