Skip to content

Commit

Permalink
make docs build successfully , activate dochack (#426)
Browse files Browse the repository at this point in the history
* make docs more compliant with rst

* fix documentation in header of einsum

* fix openmp import path in `blas_l3_gemm_macro_kernel.nim`

* fix type import in nnpack_interface.nim

* make all `noInit` pragmas consistent

Well, nim still complains. All `noInit` pragmas should be the other
way round I fear. :|

* add missing import for `auxiliary_lapack` "main module"

* [laser] disallow `gemm_packed.nim` main proc, not compatible

I assume the `when isMainModule` parts are straight from
laser. However, the tensor definitions are missing / in different
files in arraymancer and thus the code is broken.

* add code to generate nimdoc.cfg and documentation

* add updated nimdoc.cfg

* remove stray `p` from html template

We don't want every page to have a little 'p' in the bottom left
corner, do we?

* compare and emit names w/o `.html`

* add `Other docs` category and fix dir names of ag, la

* [gemm legacy] remove not used import, fix used import path

* merge nimdoc creationg into `docs', add `templates` file

* correctly set path to `source` and `edit` in docs

* add scrolling for the header

Currently setting the max size to 800 px. I'm not a css wizard, so I
don't know how to make it take into account device size.

* fix naming for layer initializations

* update nimdoc.cfg

* move doc generation to src/docs

If the files are located outside the src dir, nimble will fail to
install the package, since for some reason it does someting with its
generated nim script file from the ~/.nimble/pkg directory from which
it obviously cannot find docs / docs, since that isn't part of the
source.

* move docs back to docs/, hack around actual problem

Sorry to solve it this way. I feel like this might be a nimble
bug. Even if the files are in the actual source directory of the
package, it still says it can't import them.
  • Loading branch information
Vindaar authored Apr 6, 2020
1 parent a0bdf4e commit 2c89da8
Show file tree
Hide file tree
Showing 19 changed files with 980 additions and 378 deletions.
110 changes: 25 additions & 85 deletions arraymancer.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -229,88 +229,28 @@ task test_mkl_omp, "Run all tests - Intel MKL + OpenMP":
task test_release, "Run all tests - Release mode":
test "tests_cpu", " -d:release"

task gen_doc, "Generate Arraymancer documentation":
# TODO: Industrialize: something more robust that only check nim files (and not .DS_Store ...)
for filePath in listFiles("src/tensor/"):
let modName = filePath[11..^5] # Removing src/tensor/ (11 chars) and .nim (4 chars) # TODO: something more robust
# Cuda doc is broken https://github.com/nim-lang/Nim/issues/6910
# Delete doc comment from nimcuda before using this
exec r"nim doc -o:docs/build/tensor." & modName & ".html " & filePath

for filePath in listFiles("src/nn_primitives/"):
let modName = filePath[18..^5] # Removing src/nn_primitives/ (18 chars) and .nim (4 chars) # TODO: something more robust
# Cuda doc is broken https://github.com/nim-lang/Nim/issues/6910
# Delete doc comment from nimcuda before using this
exec r"nim doc -o:docs/build/nnp." & modName & ".html " & filePath

for filePath in listFiles("src/autograd/"):
let modName = filePath[13..^5] # Removing src/autograd/ (13 chars) and .nim (4 chars) # TODO: something more robust
exec r"nim doc -o:docs/build/ag." & modName & ".html " & filePath

for filePath in listFiles("src/nn/"):
let modName = filePath[7..^5] # Removing src/nn_primitives/ (18 chars) and .nim (4 chars) # TODO: something more robust
exec r"nim doc -o:docs/build/nn." & modName & ".html " & filePath

# TODO auto check subdir
for filePath in listFiles("src/nn/activation/"):
let modName = filePath[18..^5]
exec r"nim doc -o:docs/build/nn_activation." & modName & ".html " & filePath

for filePath in listFiles("src/nn/layers/"):
let modName = filePath[14..^5]
exec r"nim doc -o:docs/build/nn_layers." & modName & ".html " & filePath

for filePath in listFiles("src/nn/loss/"):
let modName = filePath[12..^5]
exec r"nim doc -o:docs/build/nn_loss." & modName & ".html " & filePath

for filePath in listFiles("src/nn/optimizers/"):
let modName = filePath[18..^5]
exec r"nim doc -o:docs/build/nn_optimizers." & modName & ".html " & filePath

for filePath in listFiles("src/nn_dsl/"):
let modName = filePath[11..^5]
exec r"nim doc -o:docs/build/nn_dsl." & modName & ".html " & filePath

for filePath in listFiles("src/linear_algebra/"):
let modName = filePath[19..^5]
exec r"nim doc -o:docs/build/la." & modName & ".html " & filePath

for filePath in listFiles("src/stats/"):
let modName = filePath[10..^5]
exec r"nim doc -o:docs/build/stats." & modName & ".html " & filePath

for filePath in listFiles("src/ml/clustering/"):
let modName = filePath[18..^5]
exec r"nim doc -o:docs/build/ml." & modName & ".html " & filePath

for filePath in listFiles("src/ml/dimensionality_reduction/"):
let modName = filePath[32..^5]
exec r"nim doc -o:docs/build/ml." & modName & ".html " & filePath

for filePath in listFiles("src/ml/metrics/"):
let modName = filePath[15..^5]
exec r"nim doc -o:docs/build/ml." & modName & ".html " & filePath

block:
let filePath = "src/nlp/tokenizers.nim"
let modName = filePath[8..^5]
exec r"nim doc -o:docs/build/nlp." & modName & ".html " & filePath

for filePath in listFiles("src/io/"):
let modName = filePath[7..^5]
exec r"nim doc -o:docs/build/io." & modName & ".html " & filePath

for filePath in listFiles("src/datasets/"):
let modName = filePath[13..^5]
exec r"nim doc -o:docs/build/datasets." & modName & ".html " & filePath

# Process the rst
for filePath in listFiles("docs/"):
if filePath[^4..^1] == ".rst":
let modName = filePath[5..^5]
exec r"nim rst2html -o:docs/build/" & modName & ".html " & filePath

# Copy stylesheets
cpFile("docs/docutils.css", "docs/build/docutils.css")
cpFile("docs/nav.css", "docs/build/nav.css")

template canImport(x: untyped): untyped =
compiles:
import x

when canImport(docs / docs):
# can define the `gen_docs` task (docs already imported now)
# this is to hack around weird nimble + nimscript behavior.
# when overwriting an install nimble will try to parse the generated
# nimscript file and for some reason then it won't be able to import
# the module (even if it's put into `src/`).
task gen_docs, "Generate Arraymancer documentation":
# generate nimdoc.cfg file so we can generate the correct header for the
# index.html page without having to mess with the HTML manually.
genNimdocCfg("src/")
# build the actual docs and the index
buildDocs("src/", "docs/build")
# Copy our stylesheets
cpFile("docs/docutils.css", "docs/build/docutils.css")
cpFile("docs/nav.css", "docs/build/nav.css")
# Process the rst
for filePath in listFiles("docs/"):
if filePath[^4..^1] == ".rst":
let modName = filePath[5..^5]
exec r"nim rst2html -o:docs/build/" & modName & ".html " & filePath
Loading

0 comments on commit 2c89da8

Please sign in to comment.