Skip to content

Commit fbefd20

Browse files
vdusekclaude
andauthored
docs: remove redundant transformDocs.js and pydoc-markdown setup (#677)
## Summary - Same as in apify/apify-sdk-python#834 - Remove redundant `transformDocs.js` and `pydoc-markdown` and other relevant part of code - Align versioned docs sidebar and its content (same as it is for JS projects) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d1d09e4 commit fbefd20

File tree

18 files changed

+140
-523
lines changed

18 files changed

+140
-523
lines changed

website/build_api_reference.sh

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
11
#!/bin/bash
22

3-
# On macOS, sed requires a space between -i and '' to specify no backup should be done
4-
# On Linux, sed requires no space between -i and '' to specify no backup should be done
5-
sed_no_backup() {
6-
if [[ $(uname) = "Darwin" ]]; then
7-
sed -i '' "$@"
8-
else
9-
sed -i'' "$@"
10-
fi
11-
}
12-
13-
# Create docspec dump of this package's source code through pydoc-markdown
14-
pydoc-markdown --quiet --dump > docspec-dump.jsonl
15-
sed_no_backup "s#${PWD}/..#REPO_ROOT_PLACEHOLDER#g" docspec-dump.jsonl
16-
173
# Generate import shortcuts from the modules
184
python generate_module_shortcuts.py
19-
20-
# Transform the docpec dumps into Typedoc-compatible docs tree
21-
node transformDocs.js

website/docusaurus.config.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,29 @@ const { join, resolve } = require('node:path');
33
const { config } = require('@apify/docs-theme');
44

55
const { externalLinkProcessor } = require('./tools/utils/externalLink');
6-
const { groupSort } = require('./transformDocs.js');
76
const versions = require('./versions.json');
87

8+
const GROUP_ORDER = [
9+
'Apify API clients',
10+
'HTTP clients',
11+
'Resource clients',
12+
'Errors',
13+
'Models',
14+
'Other',
15+
];
16+
17+
const groupSort = (g1, g2) => {
18+
const i1 = GROUP_ORDER.indexOf(g1);
19+
const i2 = GROUP_ORDER.indexOf(g2);
20+
// Both known – sort by defined order
21+
if (i1 !== -1 && i2 !== -1) return i1 - i2;
22+
// Unknown groups go after known ones
23+
if (i1 !== -1) return -1;
24+
if (i2 !== -1) return 1;
25+
// Both unknown – alphabetical
26+
return g1.localeCompare(g2);
27+
};
28+
929
const { absoluteUrl } = config;
1030

1131
/** @type {Partial<import('@docusaurus/types').DocusaurusConfig>} */
@@ -46,19 +66,21 @@ module.exports = {
4666
title: 'API Client for Python',
4767
items: [
4868
{
49-
to: 'docs',
69+
type: 'doc',
70+
docId: 'introduction/introduction',
5071
label: 'Docs',
5172
position: 'left',
5273
activeBaseRegex: '/docs(?!/changelog)',
5374
},
5475
{
55-
to: '/reference',
76+
type: 'custom-versioned-reference',
5677
label: 'Reference',
5778
position: 'left',
5879
activeBaseRegex: '/reference',
5980
},
6081
{
61-
to: 'docs/changelog',
82+
type: 'doc',
83+
docId: 'changelog',
6284
label: 'Changelog',
6385
position: 'left',
6486
activeBaseRegex: '/docs/changelog',
@@ -109,7 +131,6 @@ module.exports = {
109131
typedocOptions: {
110132
excludeExternals: false,
111133
},
112-
pathToCurrentVersionTypedocJSON: `${__dirname}/api-typedoc-generated.json`,
113134
sortSidebar: groupSort,
114135
routeBasePath: 'reference',
115136
python: true,

website/pydoc-markdown.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import OriginalComponentTypes from '@theme-original/NavbarItem/ComponentTypes';
2+
import VersionedReferenceNavbarItem from './VersionedReferenceNavbarItem';
3+
4+
export default {
5+
...OriginalComponentTypes,
6+
'custom-versioned-reference': VersionedReferenceNavbarItem,
7+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import { useDocsVersionCandidates } from '@docusaurus/plugin-content-docs/client';
3+
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
4+
5+
/* eslint-disable react/prop-types */
6+
export default function VersionedReferenceNavbarItem({ docsPluginId, ...props }) {
7+
const [version] = useDocsVersionCandidates(docsPluginId);
8+
9+
// Latest version → /reference, "current" (next) → /reference/next, others → /reference/{name}
10+
let to = '/reference';
11+
if (!version.isLast) {
12+
to = `/reference/${version.name === 'current' ? 'next' : version.name}`;
13+
}
14+
15+
return <DefaultNavbarItem {...props} to={to} />;
16+
}

0 commit comments

Comments
 (0)