Skip to content

Commit 00bdd69

Browse files
committed
Fix links in docs in different environments
1 parent 876c4ea commit 00bdd69

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

.github/workflows/docs.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,23 @@ jobs:
4747
- name: Install project
4848
run: make install
4949

50-
- name: Build docs
51-
run: make docs
50+
- name: Build docs (docs)
51+
if: startsWith(github.ref, 'refs/tags')
52+
run: MDBOOK_ROOT=https://dipdup.net/docs make docs
5253

53-
- name: Deploy to GH Pages
54+
- name: Deploy to GH Pages (docs)
5455
if: startsWith(github.ref, 'refs/tags')
5556
uses: peaceiris/actions-gh-pages@v3
5657
with:
5758
github_token: ${{ secrets.GITHUB_TOKEN }}
5859
publish_dir: ./docs/dist/docs
5960
destination_dir: docs
6061

61-
- name: Deploy to GH Pages (next)
62+
- name: Build docs (docs-next)
63+
if: startsWith(github.ref, 'refs/heads')
64+
run: MDBOOK_ROOT=https://dipdup.net/docs-next make docs
65+
66+
- name: Deploy to GH Pages (docs-next)
6267
if: startsWith(github.ref, 'refs/heads')
6368
uses: peaceiris/actions-gh-pages@v3
6469
with:

docs/mdbook-summary

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# $python
2+
"""Replaces {{ #summary ...}} placeholders with links from SUMMARY.md"""
23
import json
4+
import os
35
import re
46
import sys
57
from typing import NoReturn
68

79
SUMMARY_REGEX = r'{{ *#summary (.*) *}}'
10+
MDBOOK_ROOT = os.environ.get('MDBOOK_ROOT')
811

912

1013
def _fail(message: str) -> NoReturn:
@@ -46,7 +49,14 @@ def _preprocess_content(text: str, links: dict[str, str], depth: int) -> str:
4649
if '#' in path:
4750
path, anchor = path.split('#')
4851

49-
full_path = '/'.join(['..'] * depth + [path])
52+
if MDBOOK_ROOT:
53+
root_path = path
54+
if 'http' in MDBOOK_ROOT and root_path.endswith('.md'):
55+
root_path = root_path[:-3] + '.html'
56+
full_path = os.path.join(MDBOOK_ROOT, root_path)
57+
else:
58+
full_path = '/'.join(['..'] * depth + [path])
59+
5060
try:
5161
title = links[path]
5262
except KeyError:

0 commit comments

Comments
 (0)