Skip to content

Commit e7b2263

Browse files
authored
feat: version-snapshot guides alongside API reference, fix index.md links, add released versions table (#174)
Previously, versioned folders contained only API reference YAMLs while guide pages were global (unversioned). The root `index.md` had entirely broken links. The version switcher navigated to a bare `/{ver}/` folder that has no `index.html`, causing 404s on GitHub Pages. ## Workflow (`publish-documentation.yml`) - **Guide snapshot**: copies `api-reference/guide/` into `api-reference/{ver}/guide/` immediately after API metadata generation, so each version folder contains a full snapshot of both guide and API reference - **DocFX version groups**: each group now registers two content entries — API YAMLs (`*.yml`) and guide pages (`guide/*.{md,yml}`) — producing `_docs/{ver}/` and `_docs/{ver}/guide/` in the build output - **Global TOC**: `Guide` nav link now points to `{latest}/guide/introduction.html` instead of the unversioned `guide/` - **index.md injection**: a single step builds the released versions table and substitutes both `{version}` and `{versions_section}` placeholders before `docfx build` runs (no committed artefacts) ## `api-reference/api-reference.json` Removed `guide/*.{md,yml}` from the global content entry — guide pages now exist only within versioned groups. ## `api-reference/index.md` Replaced broken links with `{version}`-placeholder paths resolved at build time. Added a `{versions_section}` placeholder that the workflow expands into a full released-versions table, e.g.: | Version | Guide | API Reference | |---------|-------|---------------| | v2.0 (latest) | [Guide](2.0/guide/introduction.html) | [API Reference](2.0/PolylineAlgorithm.html) | | v1.0 | [Guide](1.0/guide/introduction.html) | [API Reference](1.0/PolylineAlgorithm.html) | ## `docs-versioning/public/version-switcher.js` Fixed the fallback navigation branch (triggered when the user is not inside a versioned path) to resolve the site root via the `docfx:rel` meta tag and navigate to `/{ver}/PolylineAlgorithm.html` instead of the bare `/{ver}/` folder.
1 parent ceb6349 commit e7b2263

4 files changed

Lines changed: 47 additions & 14 deletions

File tree

.github/workflows/publish-documentation.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ jobs:
9191
docfx metadata assembly-metadata.json
9292
mv temp ${{ env.friendly-version }}
9393
94+
- name: 'Snapshot guide for v${{ env.friendly-version }}'
95+
shell: bash
96+
run: |
97+
cp -r api-reference/guide api-reference/${{ env.friendly-version }}/guide
98+
9499
- name: 'Discover all versions'
95100
id: discover-versions
96101
shell: bash
@@ -116,7 +121,10 @@ jobs:
116121
cp api-reference/api-reference.json /tmp/api-reference.json
117122
for ver in $(echo "${{ steps.discover-versions.outputs.versions }}" | tr ',' ' '); do
118123
jq --arg ver "$ver" --arg group "v${ver}" \
119-
'.build.content += [{"dest": "", "files": ["*.yml"], "group": $group, "src": $ver, "rootTocPath": "~/toc.html"}] |
124+
'.build.content += [
125+
{"dest": "", "files": ["*.yml"], "group": $group, "src": $ver, "rootTocPath": "~/toc.html"},
126+
{"dest": "guide", "files": ["*.{md,yml}"], "group": $group, "src": ($ver + "/guide"), "rootTocPath": "~/toc.html"}
127+
] |
120128
.build.groups = (.build.groups // {}) |
121129
.build.groups[$group] = {"dest": $ver}' \
122130
/tmp/api-reference.json > /tmp/api-reference-new.json
@@ -131,7 +139,7 @@ jobs:
131139
{
132140
echo "### YamlMime:TableOfContent"
133141
echo "- name: Guide"
134-
echo " href: guide/"
142+
echo " href: ${latest}/guide/introduction.html"
135143
echo "- name: Reference"
136144
echo " dropdown: true"
137145
echo " items:"
@@ -145,6 +153,29 @@ jobs:
145153
done
146154
} > api-reference/toc.yml
147155
156+
- name: 'Inject latest version and released versions table into index.md'
157+
shell: bash
158+
run: |
159+
latest="${{ steps.discover-versions.outputs.latest }}"
160+
{
161+
echo "## Released Versions"
162+
echo ""
163+
echo "| Version | Guide | API Reference |"
164+
echo "|---------|-------|---------------|"
165+
for ver in $(echo "${{ steps.discover-versions.outputs.versions }}" | tr ',' '\n' | sort -Vr); do
166+
if [ "$ver" = "$latest" ]; then
167+
label="v${ver} (latest)"
168+
else
169+
label="v${ver}"
170+
fi
171+
echo "| ${label} | [Guide](${ver}/guide/introduction.html) | [API Reference](${ver}/PolylineAlgorithm.html) |"
172+
done
173+
} > /tmp/versions_section.md
174+
awk '/{versions_section}/{while((getline line < "/tmp/versions_section.md") > 0) print line; close("/tmp/versions_section.md"); next} {print}' \
175+
api-reference/index.md > /tmp/index.md
176+
mv /tmp/index.md api-reference/index.md
177+
sed -i "s|{version}|${latest}|g" api-reference/index.md
178+
148179
- name: 'Build documentation'
149180
shell: bash
150181
run: docfx build api-reference/api-reference.json

api-reference/api-reference.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
{
99
"files": [
1010
"index.md",
11-
"toc.yml",
12-
"guide/*.{md,yml}"
11+
"toc.yml"
1312
],
1413
"exclude": [
1514
"_docs/**"

api-reference/docs-versioning/public/version-switcher.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
'/' + targetVersion + '/'
5454
);
5555
} else {
56-
newPathname = window.location.pathname.replace(/\/$/, '') + '/' + targetVersion + '/';
56+
var siteRootPath = new URL(getSiteRoot(), window.location.href).pathname.replace(/\/$/, '');
57+
newPathname = siteRootPath + '/' + targetVersion + '/PolylineAlgorithm.html';
5758
}
5859

5960
window.location.pathname = newPathname;

api-reference/index.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# PolylineAlgorithm API Reference
22

33
Welcome! This documentation provides guides, configuration options, examples, and FAQs for the PolylineAlgorithm library.
4-
For detailed class and method docs, see the [auto-generated API documentation](https://petesramek.github.io/polyline-algorithm-csharp/).
4+
For detailed class and method docs, see the versioned [API Reference]({version}/PolylineAlgorithm.html).
55

66
## Contents
77

8-
- [Quick Start Guide](./guide.md)
9-
- [Configuration Options](./configuration.md)
10-
- [Advanced Usage](./advanced.md)
11-
- [Examples](./examples.md)
12-
- [FAQ](./faq.md)
8+
- [Introduction]({version}/guide/introduction.html)
9+
- [Getting Started]({version}/guide/getting-started.html)
10+
- [Configuration Options]({version}/guide/configuration.html)
11+
- [Advanced Scenarios]({version}/guide/advanced-scenarios.html)
12+
- [Samples]({version}/guide/sample.html)
13+
- [FAQ]({version}/guide/faq.html)
14+
15+
{versions_section}
1316

1417
## Links
1518

16-
- [API Reference Site](https://petesramek.github.io/polyline-algorithm-csharp/)
17-
- [Contributing Guidelines](../CONTRIBUTING.md)
18-
- [Changelog](./changelog.md) (if provided)
19+
- [API Reference]({version}/PolylineAlgorithm.html)
20+
- [Contributing Guidelines](https://github.com/petesramek/polyline-algorithm-csharp/blob/main/CONTRIBUTING.md)

0 commit comments

Comments
 (0)