Skip to content

Commit cc613a3

Browse files
committed
docs: bump the docusaurus plugin
1 parent 283be92 commit cc613a3

17 files changed

+514
-788
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ build-api-reference:
4949
cd website && poetry run ./build_api_reference.sh
5050

5151
build-docs:
52-
cd website && npm clean-install && npm run build
52+
cd website && npm clean-install && poetry run npm run build
5353

5454
run-docs: build-api-reference
55-
cd website && npm clean-install && npm run start
55+
cd website && npm clean-install && poetry run npm run start

src/apify/_actor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from apify._models import ActorRun
2323
from apify._platform_event_manager import EventManager, LocalEventManager, PlatformEventManager
2424
from apify._proxy_configuration import ProxyConfiguration
25-
from apify._utils import get_system_info, is_running_in_ipython
25+
from apify._utils import get_system_info, is_running_in_ipython, docs_group, docs_name
2626
from apify.apify_storage_client import ApifyStorageClient
2727
from apify.log import _configure_logging, logger
2828
from apify.storages import Dataset, KeyValueStore, RequestQueue
@@ -38,7 +38,8 @@
3838

3939
MainReturnType = TypeVar('MainReturnType')
4040

41-
41+
@docs_name('Actor')
42+
@docs_group('Classes')
4243
class _ActorType:
4344
"""The class of `Actor`. Only make a new instance if you're absolutely sure you need to."""
4445

src/apify/_configuration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
from crawlee._utils.urls import validate_http_url
1212
from crawlee.configuration import Configuration as CrawleeConfiguration
1313

14+
from apify._utils import docs_group
1415

16+
@docs_group('Classes')
1517
class Configuration(CrawleeConfiguration):
1618
"""A class for specifying the configuration of an Actor.
1719

src/apify/_models.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
from crawlee._utils.models import timedelta_ms
1111
from crawlee._utils.urls import validate_http_url
1212

13+
from apify._utils import docs_group
1314

15+
@docs_group('Data structures')
1416
class Webhook(BaseModel):
1517
__model_config__ = ConfigDict(populate_by_name=True)
1618

@@ -28,13 +30,13 @@ class Webhook(BaseModel):
2830
Field(description='Template for the payload sent by the webook'),
2931
] = None
3032

31-
33+
@docs_group('Data structures')
3234
class ActorRunMeta(BaseModel):
3335
__model_config__ = ConfigDict(populate_by_name=True)
3436

3537
origin: Annotated[MetaOrigin, Field()]
3638

37-
39+
@docs_group('Data structures')
3840
class ActorRunStats(BaseModel):
3941
__model_config__ = ConfigDict(populate_by_name=True)
4042

@@ -54,7 +56,7 @@ class ActorRunStats(BaseModel):
5456
metamorph: Annotated[int | None, Field(alias='metamorph')] = None
5557
compute_units: Annotated[float, Field(alias='computeUnits')]
5658

57-
59+
@docs_group('Data structures')
5860
class ActorRunOptions(BaseModel):
5961
__model_config__ = ConfigDict(populate_by_name=True)
6062

@@ -63,7 +65,7 @@ class ActorRunOptions(BaseModel):
6365
memory_mbytes: Annotated[int, Field(alias='memoryMbytes')]
6466
disk_mbytes: Annotated[int, Field(alias='diskMbytes')]
6567

66-
68+
@docs_group('Data structures')
6769
class ActorRunUsage(BaseModel):
6870
__model_config__ = ConfigDict(populate_by_name=True)
6971

@@ -80,7 +82,7 @@ class ActorRunUsage(BaseModel):
8082
proxy_residential_transfer_gbytes: Annotated[float | None, Field(alias='PROXY_RESIDENTIAL_TRANSFER_GBYTES')] = None
8183
proxy_serps: Annotated[float | None, Field(alias='PROXY_SERPS')] = None
8284

83-
85+
@docs_group('Data structures')
8486
class ActorRun(BaseModel):
8587
__model_config__ = ConfigDict(populate_by_name=True)
8688

src/apify/_platform_event_manager.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
from apify.log import logger
2323

24+
from apify._utils import docs_group
25+
2426
if TYPE_CHECKING:
2527
from types import TracebackType
2628

@@ -29,12 +31,12 @@
2931

3032
__all__ = ['EventManager', 'LocalEventManager', 'PlatformEventManager']
3133

32-
34+
@docs_group('Data structures')
3335
class PersistStateEvent(BaseModel):
3436
name: Literal[Event.PERSIST_STATE]
3537
data: Annotated[EventPersistStateData, Field(default_factory=lambda: EventPersistStateData(is_migrating=False))]
3638

37-
39+
@docs_group('Data structures')
3840
class SystemInfoEventData(BaseModel):
3941
mem_avg_bytes: Annotated[float, Field(alias='memAvgBytes')]
4042
mem_current_bytes: Annotated[float, Field(alias='memCurrentBytes')]
@@ -60,27 +62,27 @@ def to_crawlee_format(self) -> EventSystemInfoData:
6062
}
6163
)
6264

63-
65+
@docs_group('Data structures')
6466
class SystemInfoEvent(BaseModel):
6567
name: Literal[Event.SYSTEM_INFO]
6668
data: SystemInfoEventData
6769

68-
70+
@docs_group('Data structures')
6971
class MigratingEvent(BaseModel):
7072
name: Literal[Event.MIGRATING]
7173
data: Annotated[EventMigratingData, Field(default_factory=EventMigratingData)]
7274

73-
75+
@docs_group('Data structures')
7476
class AbortingEvent(BaseModel):
7577
name: Literal[Event.ABORTING]
7678
data: Annotated[EventAbortingData, Field(default_factory=EventAbortingData)]
7779

78-
80+
@docs_group('Data structures')
7981
class ExitEvent(BaseModel):
8082
name: Literal[Event.EXIT]
8183
data: Annotated[EventExitData, Field(default_factory=EventExitData)]
8284

83-
85+
@docs_group('Data structures')
8486
class EventWithoutData(BaseModel):
8587
name: Literal[
8688
Event.SESSION_RETIRED,
@@ -92,12 +94,12 @@ class EventWithoutData(BaseModel):
9294
]
9395
data: Any = None
9496

95-
97+
@docs_group('Data structures')
9698
class DeprecatedEvent(BaseModel):
9799
name: Literal['cpuInfo']
98100
data: Annotated[dict[str, Any], Field(default_factory=dict)]
99101

100-
102+
@docs_group('Data structures')
101103
class UnknownEvent(BaseModel):
102104
name: str
103105
data: Annotated[dict[str, Any], Field(default_factory=dict)]
@@ -123,8 +125,7 @@ class UnknownEvent(BaseModel):
123125
UnknownEvent,
124126
]
125127
)
126-
127-
128+
@docs_group('Classes')
128129
class PlatformEventManager(EventManager):
129130
"""A class for managing Actor events.
130131

src/apify/_proxy_configuration.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
from apify._configuration import Configuration
1919
from apify.log import logger
2020

21+
from apify._utils import docs_group
22+
2123
if TYPE_CHECKING:
2224
from apify_client import ApifyClientAsync
2325
from crawlee import Request
@@ -68,6 +70,7 @@ def _check(
6870
raise ValueError(f'{error_str} does not match pattern {pattern.pattern!r}')
6971

7072

73+
@docs_group('Classes')
7174
@dataclass
7275
class ProxyInfo(CrawleeProxyInfo):
7376
"""Provides information about a proxy connection that is used for requests."""
@@ -86,7 +89,7 @@ class ProxyInfo(CrawleeProxyInfo):
8689
This parameter is optional, by default, the proxy uses all available proxy servers from all countries.
8790
"""
8891

89-
92+
@docs_group('Classes')
9093
class ProxyConfiguration(CrawleeProxyConfiguration):
9194
"""Configures a connection to a proxy server with the provided options.
9295

src/apify/_utils.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
from typing import Callable, Literal
4+
35
import builtins
46
import sys
57
from importlib import metadata
@@ -24,3 +26,29 @@ def get_system_info() -> dict:
2426

2527
def is_running_in_ipython() -> bool:
2628
return getattr(builtins, '__IPYTHON__', False)
29+
30+
GroupName = Literal['Classes', 'Abstract classes', 'Data structures', 'Errors', 'Functions']
31+
32+
def docs_group(group_name: GroupName) -> Callable: # noqa: ARG001
33+
"""Decorator to mark symbols for rendering and grouping in documentation.
34+
35+
This decorator is used purely for documentation purposes and does not alter the behavior
36+
of the decorated callable.
37+
"""
38+
39+
def wrapper(func: Callable) -> Callable:
40+
return func
41+
42+
return wrapper
43+
44+
def docs_name(symbol_name: str) -> Callable:
45+
"""Decorator for renaming symbols in documentation. This changes the rendered name of the symbol only in the web documentation.
46+
47+
This decorator is used purely for documentation purposes and does not alter the behavior
48+
of the decorated callable.
49+
"""
50+
51+
def wrapper(func: Callable) -> Callable:
52+
return func
53+
54+
return wrapper

src/apify/apify_storage_client/_apify_storage_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
from apify.apify_storage_client._request_queue_client import RequestQueueClient
1313
from apify.apify_storage_client._request_queue_collection_client import RequestQueueCollectionClient
1414

15+
from apify._utils import docs_group
1516

17+
@docs_group('Classes')
1618
class ApifyStorageClient(BaseStorageClient):
1719
"""A storage client implementation based on the Apify platform storage."""
1820

website/build_api_reference.sh

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +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-
python ./pydoc-markdown/generate_ast.py > docspec-dump.jsonl
15-
sed_no_backup "s#${PWD}/..#REPO_ROOT_PLACEHOLDER#g" docspec-dump.jsonl
16-
17-
# Create docpec dump from the right version of the apify-shared package
18-
apify_shared_version=$(python -c "import apify_shared; print(apify_shared.__version__)")
19-
apify_shared_tempdir=$(realpath "$(mktemp -d)")
20-
git clone --quiet https://github.com/apify/apify-shared-python.git "${apify_shared_tempdir}"
21-
cp ./pydoc-markdown.yml "${apify_shared_tempdir}/pydoc-markdown.yml"
22-
sed_no_backup "s#search_path: \[../src\]#search_path: \[./src\]#g" "${apify_shared_tempdir}/pydoc-markdown.yml"
23-
24-
(
25-
cd "${apify_shared_tempdir}";
26-
git checkout --quiet "v${apify_shared_version}";
27-
pydoc-markdown --quiet --dump > ./apify-shared-docspec-dump.jsonl
28-
)
29-
30-
cp "${apify_shared_tempdir}/apify-shared-docspec-dump.jsonl" .
31-
sed_no_backup "s#${apify_shared_tempdir}#REPO_ROOT_PLACEHOLDER#g" apify-shared-docspec-dump.jsonl
32-
33-
rm -rf "${apify_shared_tempdir}"
34-
353
# Generate import shortcuts from the modules
364
python generate_module_shortcuts.py
37-
38-
# Transform the docpec dumps into Typedoc-compatible docs tree
39-
node transformDocs.js

website/docusaurus.config.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
/* eslint-disable global-require,import/no-extraneous-dependencies */
1+
const path = require('path');
2+
23
const { config } = require('@apify/docs-theme');
4+
35
const { externalLinkProcessor } = require('./tools/utils/externalLink');
4-
const { groupSort } = require('./transformDocs.js');
6+
7+
const GROUP_ORDER = [
8+
'Classes',
9+
'Data structures',
10+
];
11+
12+
const groupSort = (g1, g2) => {
13+
if (GROUP_ORDER.includes(g1) && GROUP_ORDER.includes(g2)) {
14+
return GROUP_ORDER.indexOf(g1) - GROUP_ORDER.indexOf(g2);
15+
}
16+
return g1.localeCompare(g2);
17+
};
518

619
const { absoluteUrl } = config;
720

@@ -83,10 +96,18 @@ module.exports = {
8396
typedocOptions: {
8497
excludeExternals: false,
8598
},
86-
pathToCurrentVersionTypedocJSON: `${__dirname}/api-typedoc-generated.json`,
8799
sortSidebar: groupSort,
88100
routeBasePath: 'reference',
89101
python: true,
102+
pythonOptions: {
103+
pythonModulePath: path.join(__dirname, '../src/apify'),
104+
moduleShortcutsPath: path.join(__dirname, '/module_shortcuts.json'),
105+
},
106+
// reexports: [
107+
// {
108+
// url: 'http://localhost:3000/python/api/class/Dataset',
109+
// },
110+
// ],
90111
},
91112
],
92113
...config.plugins,

0 commit comments

Comments
 (0)