Skip to content

Commit

Permalink
docs: Update API docs of public components (apify#914)
Browse files Browse the repository at this point in the history
### Description

- Update API docs of public components.
- Add functions (context/crawler helpers) to a "Functions" API docs
section.

### Issues

- Closes: apify#304

### Testing

- The docs were rendered locally.

### Checklist

- [x] CI passed
  • Loading branch information
vdusek authored Jan 16, 2025
1 parent 4fa6e46 commit 3886b73
Show file tree
Hide file tree
Showing 20 changed files with 371 additions and 244 deletions.
2 changes: 1 addition & 1 deletion docs/guides/code/storages/rq_with_crawler_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

async def main() -> None:
# Create a new crawler (it can be any subclass of BasicCrawler). Request queue is a default
# request provider, it will be opened, and fully managed if not specified.
# request manager, it will be opened, and fully managed if not specified.
crawler = HttpCrawler()

# Define the default request handler, which will be called for every request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async def main() -> None:
await request_queue.add_requests_batched(['https://apify.com/', 'https://crawlee.dev/'])

# Create a new crawler (it can be any subclass of BasicCrawler) and pass the request
# list as request provider to it. It will be managed by the crawler.
# list as request manager to it. It will be managed by the crawler.
crawler = HttpCrawler(request_manager=request_queue)

# Define the default request handler, which will be called for every request.
Expand Down
16 changes: 8 additions & 8 deletions src/crawlee/_autoscaling/snapshotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ def __init__(

@classmethod
def from_config(cls, config: Configuration | None = None) -> Snapshotter:
"""Create a new instance based on the provided configuration.
"""Create a new instance based on the provided `Configuration`.
Args:
config: The configuration object. Uses the global (default) configuration if not provided.
config: The `Configuration` instance. Uses the global (default) one if not provided.
"""
config = service_locator.get_configuration()

Expand All @@ -132,7 +132,7 @@ def _get_sorted_list_by_created_at(input_list: list[T]) -> SortedList[T]:

@property
def active(self) -> bool:
"""Indicates whether the context is active."""
"""Indicate whether the context is active."""
return self._active

async def __aenter__(self) -> Snapshotter:
Expand Down Expand Up @@ -178,7 +178,7 @@ async def __aexit__(

@ensure_context
def get_memory_sample(self, duration: timedelta | None = None) -> list[Snapshot]:
"""Returns a sample of the latest memory snapshots.
"""Return a sample of the latest memory snapshots.
Args:
duration: The duration of the sample from the latest snapshot. If omitted, it returns a full history.
Expand All @@ -191,7 +191,7 @@ def get_memory_sample(self, duration: timedelta | None = None) -> list[Snapshot]

@ensure_context
def get_event_loop_sample(self, duration: timedelta | None = None) -> list[Snapshot]:
"""Returns a sample of the latest event loop snapshots.
"""Return a sample of the latest event loop snapshots.
Args:
duration: The duration of the sample from the latest snapshot. If omitted, it returns a full history.
Expand All @@ -204,7 +204,7 @@ def get_event_loop_sample(self, duration: timedelta | None = None) -> list[Snaps

@ensure_context
def get_cpu_sample(self, duration: timedelta | None = None) -> list[Snapshot]:
"""Returns a sample of the latest CPU snapshots.
"""Return a sample of the latest CPU snapshots.
Args:
duration: The duration of the sample from the latest snapshot. If omitted, it returns a full history.
Expand All @@ -217,7 +217,7 @@ def get_cpu_sample(self, duration: timedelta | None = None) -> list[Snapshot]:

@ensure_context
def get_client_sample(self, duration: timedelta | None = None) -> list[Snapshot]:
"""Returns a sample of the latest client snapshots.
"""Return a sample of the latest client snapshots.
Args:
duration: The duration of the sample from the latest snapshot. If omitted, it returns a full history.
Expand All @@ -230,7 +230,7 @@ def get_client_sample(self, duration: timedelta | None = None) -> list[Snapshot]

@staticmethod
def _get_sample(snapshots: list[Snapshot], duration: timedelta | None = None) -> list[Snapshot]:
"""Returns a time-limited sample from snapshots or full history if duration is None."""
"""Return a time-limited sample from snapshots or full history if duration is None."""
if not duration:
return snapshots

Expand Down
Loading

0 comments on commit 3886b73

Please sign in to comment.