11# Based on documentation of DFTK
2- import LibGit2
3- import Pkg
2+ using LibGit2 : LibGit2
3+ using Pkg : Pkg
44
55# To manually generate the docs:
66#
@@ -18,17 +18,15 @@ CONTINUOUS_INTEGRATION = get(ENV, "CI", nothing) == "true"
1818
1919# Python and Julia dependencies needed for running the notebooks
2020# PYDEPS = ["ase", "pymatgen"]
21- JLDEPS = [
22- Pkg. PackageSpec (url= " https://github.com/louisponet/DFControl.jl.git" ,
23- rev= LibGit2. head (ROOTPATH)), # The current DFControl
24- ]
21+ JLDEPS = [Pkg. PackageSpec (; url = " https://github.com/louisponet/DFControl.jl.git" ,
22+ rev = LibGit2. head (ROOTPATH))]
2523
2624# Setup julia dependencies for docs generation if not yet done
2725Pkg. activate (@__DIR__ )
2826if ! isfile (joinpath (@__DIR__ , " Manifest.toml" ))
29- Pkg. develop (Pkg. PackageSpec (path= ROOTPATH))
27+ Pkg. develop (Pkg. PackageSpec (; path = ROOTPATH))
3028 Pkg. instantiate ()
31- Pkg. add (url= " https://github.com/kimikage/Documenter.jl" , rev= " ansicolor" )
29+ Pkg. add (; url = " https://github.com/kimikage/Documenter.jl" , rev = " ansicolor" )
3230end
3331
3432# Setup environment for making plots
@@ -44,19 +42,24 @@ using Literate
4442# Collect examples from the example index (src/index.md)
4543# The chosen examples are taken from the examples/ folder to be processed by Literate
4644EXAMPLES = [String (m[1 ])
47- for m in match .( r" \" (examples/[^ \" ]+.md) \" " ,
48- readlines ( joinpath (SRCPATH, " index .md" )))
49- if ! isnothing (m)]
45+ for m in
46+ match .( r" \" (examples/[^ \" ]+ .md) \" " ,
47+ readlines ( joinpath (SRCPATH, " index.md " ))) if ! isnothing (m)]
5048
5149# Collect files to treat with Literate (i.e. the examples and the .jl files in the docs)
5250# The examples go to docs/literate_build/examples, the .jl files stay where they are
53- literate_files = NamedTuple{(:src , :dest , :example ), Tuple{String, String, Bool}}[(src= joinpath (ROOTPATH, splitext (file)[1 ] * " .jl" ),
54- dest= joinpath (SRCPATH, " examples" ), example= true )
55- for file in EXAMPLES]
51+ literate_files = NamedTuple{(:src , :dest , :example ),Tuple{String,String,Bool}}[(src = joinpath (ROOTPATH,
52+ splitext (file)[1 ] *
53+ " .jl" ),
54+ dest = joinpath (SRCPATH,
55+ " examples" ),
56+ example = true )
57+ for file in
58+ EXAMPLES]
5659for (dir, directories, files) in walkdir (SRCPATH)
5760 for file in files
5861 if endswith (file, " .jl" )
59- push! (literate_files, (src= joinpath (dir, file), dest= dir, example= false ))
62+ push! (literate_files, (src = joinpath (dir, file), dest = dir, example = false ))
6063 end
6164 end
6265end
@@ -68,56 +71,44 @@ for file in literate_files
6871 # preprocess=preprocess)
6972 # Literate.notebook(file.src, file.dest; credit=false,
7073 # execute=CONTINUOUS_INTEGRATION || DEBUG)
71- Literate. markdown (file. src, file. dest; documenter= true , credit= false )
72- Literate. notebook (file. src, file. dest; credit= false ,
73- execute= CONTINUOUS_INTEGRATION || DEBUG)
74+ Literate. markdown (file. src, file. dest; documenter = true , credit = false )
75+ Literate. notebook (file. src, file. dest; credit = false ,
76+ execute = CONTINUOUS_INTEGRATION || DEBUG)
7477end
7578
7679# Generate the docs in BUILDPATH
77- makedocs (
78- modules = [DFControl],
79- format = Documenter. HTML (
80- # Use clean URLs, unless built as a "local" build
81- prettyurls = CONTINUOUS_INTEGRATION,
82- canonical = " https://louisponet.github.io/DFControl.jl/stable/" ,
83- assets = [" assets/favicon.ico" ],
84- ),
85- sitename = " DFControl.jl" ,
86- authors = " Louis Ponet" ,
87- linkcheck = false , # TODO
88- linkcheck_ignore = [
89- # Ignore links that point to GitHub's edit pages, as they redirect to the
90- # login screen and cause a warning:
91- r" https://github.com/([A-Za-z0-9_.-]+)/([A-Za-z0-9_.-]+)/edit(.*)" ,
92- ],
93- pages = [
94- " Home" => " index.md" ,
95- " Getting started" => Any[
96- " guide/installation.md" ,
97- " guide/configuration.md" ,
98- " Basic Tutorial" => " guide/basic_tutorial.md" ,
99- " Advanced Tutorial" => " guide/advanced_tutorial.md"
100- ],
101- " Usage" => Any[
102- " guide/jobs.md" ,
103- " guide/calculations.md" ,
104- " guide/structure.md" ,
105- ],
106- # "Examples" => EXAMPLES,
107- " api.md" ,
108- # "publications.md",
109- ],
110- # strict = !DEBUG,
111- )
80+ makedocs (; modules = [DFControl],
81+ format = Documenter. HTML (
82+ # Use clean URLs, unless built as a "local" build
83+ ; prettyurls = CONTINUOUS_INTEGRATION,
84+ canonical = " https://louisponet.github.io/DFControl.jl/stable/" ,
85+ assets = [" assets/favicon.ico" ]),
86+ sitename = " DFControl.jl" , authors = " Louis Ponet" , linkcheck = false , # TODO
87+ linkcheck_ignore = [
88+ # Ignore links that point to GitHub's edit pages, as they redirect to the
89+ # login screen and cause a warning:
90+ r" https://github.com/([A-Za-z0-9_.-]+)/([A-Za-z0-9_.-]+)/edit(.*)" ],
91+ pages = [" Home" => " index.md" ,
92+ " Getting started" => Any[" guide/installation.md" ,
93+ " guide/configuration.md" ,
94+ " Basic Tutorial" => " guide/basic_tutorial.md" ,
95+ " Advanced Tutorial" => " guide/advanced_tutorial.md" ],
96+ " Usage" => Any[" guide/jobs.md" , " guide/calculations.md" ,
97+ " guide/structure.md" ,],
98+ # "Examples" => EXAMPLES,
99+ " api.md"
100+ # "publications.md",
101+ ]
102+ # strict = !DEBUG,
103+ )
112104
113105# Dump files for managing dependencies in binder
114106if CONTINUOUS_INTEGRATION
115107 cd (BUILDPATH) do
116108 open (" environment.yml" , " w" ) do io
117- print (io,
118- """
119- name: dfcontrol
120- """ )
109+ return print (io, """
110+ name: dfcontrol
111+ """ )
121112 end
122113
123114 # Install Julia dependencies into build
@@ -130,16 +121,14 @@ if CONTINUOUS_INTEGRATION
130121end
131122
132123# Deploy docs to gh-pages branch
133- deploydocs (
134- repo = " github.com/louisponet/DFControl.jl.git" ,
135- )
124+ deploydocs (; repo = " github.com/louisponet/DFControl.jl.git" )
136125
137126# Remove generated example files
138127if ! DEBUG
139128 for file in literate_files
140129 base = splitext (basename (file. src))[1 ]
141130 for ext in [" .ipynb" , " .md" ]
142- rm (joinpath (file. dest, base * ext), force= true )
131+ rm (joinpath (file. dest, base * ext); force = true )
143132 end
144133 end
145134end
0 commit comments