From f1b34d1dc705981b850e12946a3f82bde686e7b7 Mon Sep 17 00:00:00 2001 From: MichelJuillard Date: Wed, 31 Jul 2024 17:48:13 +0200 Subject: [PATCH] adding documentation PDF file --- docs/make.jl | 70 +++++++++++++++++++++++++++++++++-------------- docs/src/index.md | 2 ++ 2 files changed, 51 insertions(+), 21 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index 9b9fe289..d80965cf 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,34 +1,62 @@ using Documenter, Dynare +# A flag to check if we are running in a GitHub action. +const _IS_GITHUB_ACTIONS = get(ENV, "GITHUB_ACTIONS", "false") == "true" + +# Pass --pdf to build the PDF. On GitHub actions, we always build the PDF. +const _PDF = findfirst(isequal("--pdf"), ARGS) !== nothing || _IS_GITHUB_ACTIONS +_PAGES =[ + "Home" => "index.md", + "Installation and Configuration" => "installation-and-configuration.md", + "Running Dynare" => "running-dynare.md", + "Model File" => [ + "Syntax elements" => "model-file/syntax-elements.md", + "Variables and parameters declaration" => "model-file/variable-declarations.md", + "Model declaration" => "model-file/model-declaration.md", + # "Initial and terminal conditions" => "model-file/initial-terminal-conditions.md", + "Steady state" => "model-file/steady-state.md", + "Shocks on exgogenous variables" => "model-file/shocks.md", + "Deterministic simulations" => "model-file/deterministic-simulations.md", + "Local approximation" => "model-file/local-approxiation.md", + "State space, filtering and smoothing" => "model-file/filtersmoother.md", + "Estimation" => "model-file/estimation.md", + "Forecasting" => "model-file/forecasting.md", + "Reporting"=> "model-file/reporting.md", + # "Optimal policy" => "model-file/optimal-policy.md", + ], + "Macroprocessing language" => "macroprocessor.md" +] + +# Needed to make Documenter think that there is a PDF in the right place when +# link checking. Inn production we replace this by running the LaTeX build. +write(joinpath(@__DIR__, "src", "Dynare.pdf"), "") + makedocs( sitename="Dynare.jl", format=Documenter.HTML(; prettyurls=get(ENV, "CI", nothing) == "true"), # doctest = false, - pages=[ - "Home" => "index.md", - "Installation and Configuration" => "installation-and-configuration.md", - "Running Dynare" => "running-dynare.md", - "Model File" => [ - "Syntax elements" => "model-file/syntax-elements.md", - "Variables and parameters declaration" => "model-file/variable-declarations.md", - "Model declaration" => "model-file/model-declaration.md", -# "Initial and terminal conditions" => "model-file/initial-terminal-conditions.md", - "Steady state" => "model-file/steady-state.md", - "Shocks on exgogenous variables" => "model-file/shocks.md", - "Deterministic simulations" => "model-file/deterministic-simulations.md", - "Local approximation" => "model-file/local-approxiation.md", - "State space, filtering and smoothing" => "model-file/filtersmoother.md", - "Estimation" => "model-file/estimation.md", - "Forecasting" => "model-file/forecasting.md", - "Reporting"=> "model-file/reporting.md", -# "Optimal policy" => "model-file/optimal-policy.md", - ], - "Macroprocessing language" => "macroprocessor.md" - ], + pages = _PAGES, pagesonly = true, ) +latex_platform = _IS_GITHUB_ACTIONS ? "docker" : "native" +makedocs( + sitename = "Dynare", + format = Documenter.LaTeX(; platform = latex_platform), + build = "latex_build", + pages = _PAGES, + pagesonly = true, + debug = true, + ) + # Hack for deploying: copy the pdf (and only the PDF) into the HTML build + # directory! We don't want to copy everything in `latex_build` because it + # includes lots of extraneous LaTeX files. + cp( + joinpath(@__DIR__, "latex_build", "Dynare.pdf"), + joinpath(@__DIR__, "build", "Dynare.pdf"); + force = true, + ) deploydocs( repo="github.com/DynareJulia/Dynare.jl.git", push_preview=true ) diff --git a/docs/src/index.md b/docs/src/index.md index 20eceef3..b9dd1ec5 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -1,6 +1,8 @@ # The Dynare Julia Reference Manual # Introduction +!!! note This documentation is also available in PDF format: [Dynare.pdf](Dynare.pdf). + DynareJulia is a rewriting of Dynare (https://www.dynare.org) that was initially written in Gauss in 1994 and rewritten in Matlab around 2000.