Files
JuliaFEM.jl/docs/build_api.jl
T

72 lines
2.3 KiB
Julia
Raw Normal View History

2015-06-26 18:44:20 +03:00
using Docile, Lexicon, JuliaFEM
const api_directory = "api"
2015-07-05 11:22:28 +03:00
"""
Searches recursively all the modules from packages. As documentation grows, it's a bit
2015-07-05 11:26:26 +03:00
troublesome to add all the new modules manually, so this function searches all the modules
automatically.
2015-07-05 11:22:28 +03:00
Parameters
----------
module_: Module
Module where we want to search modules inside
append_list: Array{Module, 1}
Array, where we append Modules as we find them
Returns
-------
None. Void function, which manipulates the append_list
"""
function search_modules!(module_::Module, append_list::Array{Module, 1})
all_names = names(module_, true)
for each in all_names
inner_module = module_.(each)
if (typeof(inner_module) == Module) && !(inner_module in append_list)
push!(append_list, inner_module)
search_modules!(inner_module, append_list)
end
end
end
2015-07-05 20:30:08 +03:00
append_list = Array(Module, 0)
2015-07-05 11:22:28 +03:00
search_modules!(JuliaFEM, append_list)
const modules = append_list
2015-06-26 18:44:20 +03:00
2015-06-26 19:53:42 +03:00
# main_folder = dirname(dirname(@__FILE__))
# this_folder = dirname(@__FILE__)
2015-06-26 19:33:49 +03:00
2015-06-26 19:53:42 +03:00
# file_ = "README.md"
# run(`cp $main_folder/$file_ $this_folder`)
2015-06-26 19:33:49 +03:00
2015-06-26 18:44:20 +03:00
cd(dirname(@__FILE__)) do
2015-06-26 20:10:47 +03:00
# Run the doctests *before* we start to generate *any* documentation.
2015-07-30 20:41:52 +03:00
# for m in modules
# failures = failed(doctest(m))
# if !isempty(failures.results)
# println("\nDoctests failed, aborting commit.\n")
# display(failures)
# exit(1) # Bail when doctests fail.
# end
# end
2015-06-26 18:44:20 +03:00
# Generate and save the contents of docstrings as markdown files.
index = Index()
for mod in modules
2015-08-25 21:32:43 +03:00
Lexicon.update!(index, save(joinpath(api_directory, "$(mod).rst"), mod))
2015-06-26 18:44:20 +03:00
end
2015-08-01 15:50:52 +03:00
save(joinpath(api_directory, "index.rst"), index)
2015-06-26 18:44:20 +03:00
# Add a reminder not to edit the generated files.
2015-07-30 20:41:52 +03:00
# open(joinpath(api_directory, "README.md"), "w") do f
# print(f, """
# Files in this directory are generated using the `build.jl` script. Make
# all changes to the originating docstrings/files rather than these ones.
# """)
# end
2015-07-30 20:40:14 +03:00
# save(joinpath(api_directory, "index.rst"), index; md_subheader = :category)
2015-07-03 22:32:20 +03:00
# info("Adding all documentation changes in $(api_directory) to this commit.")
# success(`git add $(api_directory)`) || exit(1)
2015-06-26 18:44:20 +03:00
end