From e4d49a89e05d6e45f59df6b2c50d4e55f580806b Mon Sep 17 00:00:00 2001 From: Iblis Lin Date: Tue, 8 Oct 2019 21:47:00 +0800 Subject: [PATCH] julia/docs: more DRY on page rendering --- julia/docs/Project.toml | 2 +- julia/docs/make.jl | 33 +++++++++++++++++++++++++++++ julia/docs/mkdocs.yml | 1 + julia/docs/src/api.md | 15 +------------ julia/docs/src/api/ndarray.md | 20 ++--------------- julia/docs/src/api/symbolic-node.md | 11 +--------- julia/docs/src/index.md | 16 ++------------ julia/src/executor.jl | 2 +- julia/src/symbolic-node/show.jl | 2 +- 9 files changed, 43 insertions(+), 59 deletions(-) diff --git a/julia/docs/Project.toml b/julia/docs/Project.toml index a4b243b0ffea..023a222beba6 100644 --- a/julia/docs/Project.toml +++ b/julia/docs/Project.toml @@ -4,4 +4,4 @@ DocumenterMarkdown = "997ab1e6-3595-5248-9280-8efb232c3433" MXNet = "a7949054-b901-59c6-b8e3-7238c29bf7f0" [compat] -Documenter = "~0.21" +Documenter = "~0.23" diff --git a/julia/docs/make.jl b/julia/docs/make.jl index 3e541c636888..3ea9b07d1056 100644 --- a/julia/docs/make.jl +++ b/julia/docs/make.jl @@ -19,6 +19,39 @@ using Documenter using DocumenterMarkdown using MXNet +""" +Return all files of a submodule + +julia> listpages("ndarray") +15-element Array{String,1}: + "ndarray.jl" + "ndarray/activation.jl" + "ndarray/arithmetic.jl" + "ndarray/array.jl" + ... + "ndarray/statistic.jl" + "ndarray/trig.jl" + "ndarray/type.jl" +""" +listpages(x) = + ["$x.jl"; joinpath.(x, readdir(joinpath(@__DIR__, "..", "src", x)))] + +const api_pages = [ + "api/context.md", + "api/ndarray.md", + "api/symbolic-node.md", + "api/model.md", + "api/initializers.md", + "api/optimizers.md", + "api/callbacks.md", + "api/metric.md", + "api/io.md", + "api/nn-factory.md", + "api/executor.md", + "api/kvstore.md", + "api/visualize.md", +] + makedocs( sitename = "MXNet.jl", modules = MXNet, diff --git a/julia/docs/mkdocs.yml b/julia/docs/mkdocs.yml index 22cb71869673..383505621540 100644 --- a/julia/docs/mkdocs.yml +++ b/julia/docs/mkdocs.yml @@ -62,4 +62,5 @@ nav: - Symbolic API: api/symbolic-node.md - Neural Networks Factory: api/nn-factory.md - Executor: api/executor.md + - Key-Value Store: api/kvstore.md - Network Visualization: api/visualize.md diff --git a/julia/docs/src/api.md b/julia/docs/src/api.md index 60cb0831d1bf..04cfadd6d698 100644 --- a/julia/docs/src/api.md +++ b/julia/docs/src/api.md @@ -18,18 +18,5 @@ # API Documentation ```@contents -Pages = [ - "api/symbolic-node.md", - "api/ndarray.md", - "api/context.md", - "api/model.md", - "api/initializers.md", - "api/optimizers.md", - "api/callbacks.md", - "api/metric.md", - "api/io.md", - "api/nn-factory.md", - "api/executor.md", - "api/visualize.md", -] +Pages = api_pages ``` diff --git a/julia/docs/src/api/ndarray.md b/julia/docs/src/api/ndarray.md index 64f59dc5393e..640e8b3ec372 100644 --- a/julia/docs/src/api/ndarray.md +++ b/julia/docs/src/api/ndarray.md @@ -19,7 +19,7 @@ ## Arithmetic Operations -In the following example `y` can be a `Real` value or another `NDArray` +In the following example `y` can be a `Real` value or another `NDArray`. | API | Example | | |-----|----------|----------------------------| @@ -70,21 +70,5 @@ In the following example `y` can be a `Real` value or another `NDArray` ```@autodocs Modules = [MXNet.mx] -Pages = [ - "ndarray.jl", - "ndarray/activation.jl", - "ndarray/arithmetic.jl", - "ndarray/array.jl", - "ndarray/autoimport.jl", - "ndarray/comparison.jl", - "ndarray/context.jl", - "ndarray/io.jl", - "ndarray/linalg.jl", - "ndarray/reduction.jl", - "ndarray/remap.jl", - "ndarray/show.jl", - "ndarray/statistic.jl", - "ndarray/trig.jl", - "ndarray/type.jl", -] +Pages = listpages("ndarray") ``` diff --git a/julia/docs/src/api/symbolic-node.md b/julia/docs/src/api/symbolic-node.md index 0efe4605c414..785dda87fbde 100644 --- a/julia/docs/src/api/symbolic-node.md +++ b/julia/docs/src/api/symbolic-node.md @@ -19,14 +19,5 @@ ```@autodocs Modules = [MXNet.mx] -Pages = [ - "symbolic-node.jl", - "symbolic-node/arithmetic.jl", - "symbolic-node/array.jl", - "symbolic-node/autodiff.jl", - "symbolic-node/io.jl", - "symbolic-node/op.jl", - "symbolic-node/show.jl", - "symbolic-node/type.jl", -] +Pages = listpages("symbolic-node") ``` diff --git a/julia/docs/src/index.md b/julia/docs/src/index.md index aacd844cc38e..4213265b4bd4 100644 --- a/julia/docs/src/index.md +++ b/julia/docs/src/index.md @@ -55,18 +55,6 @@ Depth = 2 ## API Documentation ```@contents -Pages = [ - "api/context.md", - "api/ndarray.md", - "api/symbolic-node.md", - "api/model.md", - "api/initializers.md", - "api/optimizers.md", - "api/callbacks.md", - "api/metric.md", - "api/io.md", - "api/nn-factory.md", - "api/executor.md", - "api/visualize.md", -] +Pages = api_pages +Depth = 2 ``` diff --git a/julia/src/executor.jl b/julia/src/executor.jl index 37f2dde615b8..7f6c2bb5aa58 100644 --- a/julia/src/executor.jl +++ b/julia/src/executor.jl @@ -245,7 +245,7 @@ Total 11 TempSpace resource requested ``` """ Base.print(io::IO, x::Executor) = print(io, debug_str(x)) -Base.print(x::Executor) = print(STDOUT, x) +Base.print(x::Executor) = print(stdout, x) function debug_str(x::Executor) s_ref = Ref{Cstring}(C_NULL) diff --git a/julia/src/symbolic-node/show.jl b/julia/src/symbolic-node/show.jl index f07c6b4655ee..9d40ea124505 100644 --- a/julia/src/symbolic-node/show.jl +++ b/julia/src/symbolic-node/show.jl @@ -57,6 +57,6 @@ function Base.print(io::IO, sym::SymbolicNode) print(io, unsafe_string(out[])) end -Base.print(sym::SymbolicNode) = print(STDOUT, sym) +Base.print(sym::SymbolicNode) = print(stdout, sym)