Skip to content

Commit 60c23a8

Browse files
committed
documenter vitepress
1 parent bbef495 commit 60c23a8

10 files changed

Lines changed: 370 additions & 167 deletions

File tree

.github/workflows/deploy_docs.yml

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,52 @@
1-
name: Deploy Documenter.jl generated documentation
1+
name: Docs build and deploy
22

33
on:
4+
pull_request:
5+
branches:
6+
- main
47
push:
58
branches:
69
- main
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: write
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
17+
cancel-in-progress: true
718

819
jobs:
9-
deploy:
20+
build-and-deploy:
1021
runs-on: ubuntu-latest
1122

1223
steps:
13-
- name: Checkout repository
14-
uses: actions/checkout@v3
24+
- name: Checkout
25+
uses: actions/checkout@v6
26+
with:
27+
persist-credentials: false
28+
29+
- name: Install python
30+
uses: actions/setup-python@v6
1531
with:
16-
fetch-depth: 1 # Only fetch the latest commit to keep the job light.
32+
python-version: "3.8"
1733

18-
- name: Set up Julia
19-
uses: julia-actions/setup-julia@v1
34+
- name: Install Julia
35+
uses: julia-actions/setup-julia@v2
2036
with:
21-
version: "1.12"
37+
version: "1"
2238

23-
- name: Install dependencies
24-
run: |
25-
cd docs
26-
julia --project -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd()*"/../")); Pkg.add(url="https://github.com/rbeeli/Documenter.jl"); Pkg.resolve(); Pkg.instantiate()'
39+
- uses: julia-actions/cache@v3
2740

28-
- name: Build documentation
29-
run: |
30-
cd docs
31-
julia --project make.jl
41+
- name: Build and deploy docs
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: >
45+
cd docs;
46+
julia --color=yes makedocs.jl
3247
33-
- name: Deploy to GitHub Pages
34-
uses: peaceiris/actions-gh-pages@v3
48+
- name: Upload site as artifact
49+
uses: actions/upload-artifact@v7
3550
with:
36-
github_token: ${{ secrets.GITHUB_TOKEN }}
37-
publish_dir: docs/build
38-
force_orphan: true
51+
name: Docs build
52+
path: ./docs/build

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ deps/src/
1616
# Build artifacts for creating documentation generated by the Documenter package
1717
docs/site/
1818
docs/build/
19+
docs/node_modules/
20+
docs/package-lock.json
1921
docs/src/examples/gen/
2022
docs/src/integrations/gen/
2123
docs/src/plotting/gen/
@@ -24,7 +26,7 @@ docs/src/plotting/gen/
2426
# It records a fixed state of all packages used by the project. As such, it should not be
2527
# committed for packages, but should be committed for applications that require a static
2628
# environment.
27-
Manifest.toml
29+
Manifest*.toml
2830

2931
.vscode/
3032

CONTRIBUTING.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,16 @@ For a backtesting engine like Fastback.jl, the most common missing built‑ins I
104104

105105
## Building documentation
106106

107-
The documentation is built using [Documenter.jl](https://documenter.juliadocs.org/stable/).
107+
The documentation is built using [Documenter.jl](https://documenter.juliadocs.org/stable/) and [DocumenterVitepress.jl](https://github.com/LuxDL/DocumenterVitepress.jl).
108108

109109
To rebuild, run the following command from the root of the repository:
110110

111111
```bash
112-
cd docs
113-
julia --project --eval 'using Pkg; Pkg.resolve(); Pkg.instantiate()'
114-
julia --project make.jl
112+
julia --project=docs docs/makedocs.jl
115113
```
116114

117115
To view the documentation locally, run:
118116

119117
```bash
120-
cd docs
121-
npx live-server ./build
118+
just serve-docs
122119
```

docs/Project.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@ Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
44
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
55
DisplayAs = "0b91fe84-8a4c-11e9-3e1d-67c38462b6d6"
66
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
7+
DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365"
78
Fastback = "2b92286b-cbc8-46f1-be48-a629b4baefca"
89
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
910
Measures = "442fdcdd-2543-5da2-b0f3-8c86c306513e"
1011
NanoDates = "46f1a544-deae-4307-8689-c12aa3c955c6"
12+
NodeJS = "2bd173c7-0d6d-553b-b6af-13a54713934c"
1113
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1214
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
1315
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1416
Query = "1a8c2f83-1ff3-5112-b086-8aa67b057ba1"
1517
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1618
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
1719
Timestamps64 = "bb4eac3f-01a0-4c2b-bd7e-ee6d71616039"
20+
21+
[compat]
22+
Documenter = "1"
23+
DocumenterVitepress = "0.2.4"
24+
NodeJS = "2"

docs/make.jl

Lines changed: 1 addition & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1 @@
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

Comments
 (0)