Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

docs: Add @docs_group decorator #655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 11, 2024
Merged

docs: Add @docs_group decorator #655

merged 6 commits into from
Nov 11, 2024

Conversation

barjin
Copy link
Contributor

@barjin barjin commented Nov 6, 2024

Adds support for the @docs_group decorator, which sets the symbol's group in the documentation.

Adds the decorators as per the list in #650 .

Hides the undecorated symbols under the project root (but keeps those in classes etc., so class / object methods + properties are still documented).

obrazek

Closes #650

@barjin barjin requested review from janbuchar and vdusek November 6, 2024 08:19
@barjin barjin self-assigned this Nov 6, 2024
@github-actions github-actions bot added this to the 102nd sprint - Tooling team milestone Nov 6, 2024
@github-actions github-actions bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Nov 6, 2024
@@ -0,0 +1,2 @@
def docs_group(group_name: str) -> None:
pass
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This likely breaks all the code and needs fixing.

All the "noop" decorator approaches (that work for both classes and functions) I found had way too many lines - definitely more than I'm comfortable with changing :)

Can one of you Python whizzes fix this please? (cc @vdusek @Pijukatel )

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this should work:

class docs_group:
  def __init__(self, group_name: str) -> None:
    pass

  def __call__(self, callable: Callable) -> Callable:
    return callable

You could also make a function that returns a function, but I tend to find that a class is more readable.

src/crawlee/_autoscaling/autoscaled_pool.py Show resolved Hide resolved
@@ -0,0 +1,2 @@
def docs_group(group_name: str) -> None:
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this should work:

class docs_group:
  def __init__(self, group_name: str) -> None:
    pass

  def __call__(self, callable: Callable) -> Callable:
    return callable

You could also make a function that returns a function, but I tend to find that a class is more readable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is supposed to be used as a singleton:

from crawlee import service_container

client = service_container.get_storage_client()

But this will probably change soon anyway...

@@ -77,27 +79,26 @@ const groupSort = (g1, g2) => {
};

function getGroupName(object) {
if (object.decorations?.some(d => d.name === 'docs_group')) {
return {
groupName: object.decorations.find(d => d.name === 'docs_group')?.args.slice(2,-2),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That slice is disturbing. But I guess AST parsing is overkill for this case.

@vdusek vdusek changed the title docs: @docs_group decorator docs: Add @docs_group decorator Nov 11, 2024
@vdusek vdusek requested a review from janbuchar November 11, 2024 16:09
Copy link
Collaborator

@vdusek vdusek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vdusek vdusek merged commit 9ce6e14 into master Nov 11, 2024
22 of 23 checks passed
@vdusek vdusek deleted the docs/group-by-decorator branch November 11, 2024 16:29
janbuchar pushed a commit to apify/apify-sdk-python that referenced this pull request Nov 20, 2024
Updates the `@apify/docusaurus-plugin-typedoc-api` plugin, which enables
us to use the unified Python documentation pipeline (instead of handling
it in each Python project separately).

Decorates the symbols to be documented with `@docs_group` and
`@docs_name` decorators (just like in
[crawlee-python](apify/crawlee-python#655)).
Those decorators could be moved up into some shared package (e.g.
`apify-shared`, which already has the `@ignore_docs` decorator).

Uses the new `reexports` feature of the plugin to load external API docs
(from `crawlee.dev/python`) and re-render them in the current
documentation instance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-tooling Issues with this label are in the ownership of the tooling team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rendering symbol groups in API docs
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.