|
1 | | -const DOCS_ROOT = @__DIR__ |
2 | | -const PROJECT_ROOT = normpath(joinpath(DOCS_ROOT, "..")) |
3 | | - |
4 | | -# GR render offscreen (avoid window popups during docs build) |
5 | | -ENV["GKS_WSTYPE"] = "100" |
6 | | - |
7 | | -# Use a wider virtual terminal for @example/@repl output so wide tables |
8 | | -# (DataFrames/PrettyTables) are not horizontally cropped in rendered docs. |
9 | | -ENV["COLUMNS"] = "160" |
10 | | -ENV["LINES"] = "80" |
11 | | - |
12 | | -using Pkg |
13 | | -Pkg.activate(DOCS_ROOT) |
14 | | -Pkg.develop(path=PROJECT_ROOT) |
15 | | -Pkg.instantiate() |
16 | | - |
17 | | -using Documenter |
18 | | -using Literate |
19 | | -using Fastback |
20 | | - |
21 | | -function postprocess_md(md, data_dir) |
22 | | - # fix data folder path |
23 | | - md = replace(md, "\"data/" => "\"$(data_dir)") |
24 | | - |
25 | | - md |
26 | | -end |
27 | | - |
28 | | -const EXAMPLES_ROOT = joinpath(DOCS_ROOT, "src", "examples") |
29 | | -const INTEGRATIONS_ROOT = joinpath(DOCS_ROOT, "src", "integrations") |
30 | | -const PLOTTING_ROOT = joinpath(DOCS_ROOT, "src", "plotting") |
31 | | -const GENERATED_EXAMPLES_ROOT = joinpath(EXAMPLES_ROOT, "gen") |
32 | | -const GENERATED_INTEGRATIONS_ROOT = joinpath(INTEGRATIONS_ROOT, "gen") |
33 | | -const GENERATED_PLOTTING_ROOT = joinpath(PLOTTING_ROOT, "gen") |
34 | | - |
35 | | -if isdir(GENERATED_EXAMPLES_ROOT) |
36 | | - rm(GENERATED_EXAMPLES_ROOT; recursive=true) |
37 | | -end |
38 | | - |
39 | | -mkpath(GENERATED_EXAMPLES_ROOT) |
40 | | - |
41 | | -if isdir(GENERATED_INTEGRATIONS_ROOT) |
42 | | - rm(GENERATED_INTEGRATIONS_ROOT; recursive=true) |
43 | | -end |
44 | | - |
45 | | -mkpath(GENERATED_INTEGRATIONS_ROOT) |
46 | | - |
47 | | -if isdir(GENERATED_PLOTTING_ROOT) |
48 | | - rm(GENERATED_PLOTTING_ROOT; recursive=true) |
49 | | -end |
50 | | - |
51 | | -mkpath(GENERATED_PLOTTING_ROOT) |
52 | | - |
53 | | -function gen_markdown(path; |
54 | | - name=nothing, |
55 | | - source_root::String=EXAMPLES_ROOT, |
56 | | - generated_root::String=GENERATED_EXAMPLES_ROOT, |
57 | | - data_dir::String="../data/") |
58 | | - kwargs = ( |
59 | | - postprocess=(md -> postprocess_md(md, data_dir)), |
60 | | - credit=false, |
61 | | - ) |
62 | | - if name === nothing |
63 | | - Literate.markdown( |
64 | | - joinpath(source_root, path), |
65 | | - generated_root; |
66 | | - kwargs...) |
67 | | - else |
68 | | - Literate.markdown( |
69 | | - joinpath(source_root, path), |
70 | | - generated_root; |
71 | | - kwargs..., |
72 | | - name=name) |
73 | | - end |
74 | | -end |
75 | | - |
76 | | -# generate markdown files |
77 | | -gen_markdown("1_random_trading.jl"); |
78 | | -gen_markdown("2_portfolio_trading.jl"); |
79 | | -gen_markdown("3_multi_currency.jl"); |
80 | | -gen_markdown("4_USDm_perp_trading.jl"); |
81 | | -gen_markdown("5_VOO_vs_MES_comparison/main.jl"; name="5_VOO_vs_MES_comparison"); |
82 | | -gen_markdown( |
83 | | - "1_Tables_integration.jl"; |
84 | | - source_root=INTEGRATIONS_ROOT, |
85 | | - generated_root=GENERATED_INTEGRATIONS_ROOT); |
86 | | -gen_markdown( |
87 | | - "2_NanoDates_integration.jl"; |
88 | | - source_root=INTEGRATIONS_ROOT, |
89 | | - generated_root=GENERATED_INTEGRATIONS_ROOT); |
90 | | -gen_markdown( |
91 | | - "3_Timestamps64_integration.jl"; |
92 | | - source_root=INTEGRATIONS_ROOT, |
93 | | - generated_root=GENERATED_INTEGRATIONS_ROOT); |
94 | | -gen_markdown( |
95 | | - "1_plots_extension.jl"; |
96 | | - source_root=PLOTTING_ROOT, |
97 | | - generated_root=GENERATED_PLOTTING_ROOT); |
98 | | - |
99 | | -makedocs( |
100 | | - sitename="Fastback.jl", |
101 | | - format=Documenter.HTML( |
102 | | - prettyurls=get(ENV, "CI", nothing) == "true", |
103 | | - sidebar_sitename=false, |
104 | | - assets=["assets/styles.css"], |
105 | | - edit_link="main" |
106 | | - ), |
107 | | - pages=[ |
108 | | - "Home" => "index.md", |
109 | | - "Getting started" => "getting_started.md", |
110 | | - "Basic setup" => "basic_setup.md", |
111 | | - "Accounting model and event loop" => "concepts.md", |
112 | | - "Execution and errors" => "execution_errors.md", |
113 | | - "Pitfalls and gotchas" => "pitfalls.md", |
114 | | - "How-to" => "how_to.md", |
115 | | - "Analytics" => "analytics.md", |
116 | | - "Examples" => [ |
117 | | - "Random trading" => "examples/gen/1_random_trading.md", |
118 | | - "Portfolio trading" => "examples/gen/2_portfolio_trading.md", |
119 | | - "Multi-Currency trading" => "examples/gen/3_multi_currency.md", |
120 | | - "USD-M perpetual trading" => "examples/gen/4_USDm_perp_trading.md", |
121 | | - "VOO vs MES cost comparison" => "examples/gen/5_VOO_vs_MES_comparison.md", |
122 | | - ], |
123 | | - "Plotting" => [ |
124 | | - "Plots extensions" => "plotting/gen/1_plots_extension.md", |
125 | | - ], |
126 | | - "Integrations" => [ |
127 | | - "Overview" => "integrations/index.md", |
128 | | - "Tables.jl" => "integrations/gen/1_Tables_integration.md", |
129 | | - "NanoDates.jl" => "integrations/gen/2_NanoDates_integration.md", |
130 | | - "Timestamps64.jl" => "integrations/gen/3_Timestamps64_integration.md", |
131 | | - ], |
132 | | - "API index" => "api_index.md", |
133 | | - "Glossary" => "glossary.md", |
134 | | - ] |
135 | | -) |
| 1 | +include(joinpath(@__DIR__, "makedocs.jl")) |
0 commit comments