Skip to content

Feature: Add a link to the Github docs for each REST endpoint #88

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Default Linux Universal",
"image": "mcr.microsoft.com/devcontainers/universal:2-linux",
"features": {
"ghcr.io/devcontainers-contrib/features/poetry:2": {}
"ghcr.io/devcontainers-contrib/features/poetry:2": {},
},
"postCreateCommand": "./scripts/setup-envs.sh",
"customizations": {
Expand All @@ -15,34 +15,34 @@
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.codeActionsOnSave": {
"source.fixAll.ruff": true,
"source.organizeImports": true
}
"source.organizeImports": true,
},
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"files.exclude": {
"**/__pycache__": true
"**/__pycache__": true,
},
"files.watcherExclude": {
"**/target/**": true,
"**/__pycache__": true
}
"**/__pycache__": true,
},
},
"extensions": [
"ms-python.python",
Expand All @@ -51,8 +51,8 @@
"ms-python.black-formatter",
"charliermarsh.ruff",
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode"
]
}
}
"esbenp.prettier-vscode",
],
},
},
}
1 change: 1 addition & 0 deletions codegen/parser/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class EndpointData:
tags: list[str] | None = None
description: str | None = None
operation_id: str | None = None
external_docs: str | None = None
deprecated: bool = False

parameters: list[Parameter] = field(default_factory=list)
Expand Down
1 change: 1 addition & 0 deletions codegen/parser/endpoints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def parse_endpoint(source: "Source", path: str) -> list[EndpointData]:
tags=operation.tags,
description=operation.description,
operation_id=operation.operationId,
external_docs=operation.externalDocs and operation.externalDocs.url,
deprecated=operation.deprecated,
parameters=global_params + op_params,
request_body=request_body,
Expand Down
8 changes: 8 additions & 0 deletions codegen/templates/rest/client.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ class {{ pascal_case(tag) }}Client:
self,
{{ endpoint_params(endpoint) | indent(8) }}
) -> {{ build_response_type(endpoint.success_response) }}:
{% if endpoint.external_docs %}
"""See also: {{ endpoint.external_docs }}"""

{% endif %}
{{ build_request(endpoint) | indent(8) }}
return self._github.request(
{{ build_request_params(endpoint) | indent(12) }}
Expand Down Expand Up @@ -122,6 +126,10 @@ class {{ pascal_case(tag) }}Client:
self,
{{ endpoint_params(endpoint) | indent(8) }}
) -> {{ build_response_type(endpoint.success_response) }}:
{% if endpoint.external_docs %}
"""See also: {{ endpoint.external_docs }}"""

{% endif %}
{{ build_request(endpoint) | indent(8) }}
return await self._github.arequest(
{{ build_request_params(endpoint) | indent(12) }}
Expand Down
14 changes: 8 additions & 6 deletions githubkit/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@
from githubkit.versions.v2022_11_28.models import ContentTraffic as ContentTraffic
from githubkit.versions.v2022_11_28.models import FullRepository as FullRepository
from githubkit.versions.v2022_11_28.models import GlobalAdvisory as GlobalAdvisory
from githubkit.versions.v2022_11_28.models import HookPropConfig as HookPropConfig
from githubkit.versions.v2022_11_28.models import LicenseContent as LicenseContent
from githubkit.versions.v2022_11_28.models import MergedUpstream as MergedUpstream
from githubkit.versions.v2022_11_28.models import PackageVersion as PackageVersion
Expand Down Expand Up @@ -2368,6 +2367,9 @@
from githubkit.versions.v2022_11_28.models import (
CodeScanningOrganizationAlertItems as CodeScanningOrganizationAlertItems,
)
from githubkit.versions.v2022_11_28.models import (
FullRepositoryPropCustomProperties as FullRepositoryPropCustomProperties,
)
from githubkit.versions.v2022_11_28.models import (
GistsGistIdGetResponse403PropBlock as GistsGistIdGetResponse403PropBlock,
)
Expand Down Expand Up @@ -3076,6 +3078,9 @@
from githubkit.versions.v2022_11_28.models import (
ReposOwnerRepoGitTagsPostBodyPropTagger as ReposOwnerRepoGitTagsPostBodyPropTagger,
)
from githubkit.versions.v2022_11_28.models import (
ReposOwnerRepoPropertiesValuesPatchBody as ReposOwnerRepoPropertiesValuesPatchBody,
)
from githubkit.versions.v2022_11_28.models import (
RepositoryRulePullRequestPropParameters as RepositoryRulePullRequestPropParameters,
)
Expand Down Expand Up @@ -3949,9 +3954,6 @@
from githubkit.versions.v2022_11_28.models import (
ReposOwnerRepoActionsWorkflowsGetResponse200 as ReposOwnerRepoActionsWorkflowsGetResponse200,
)
from githubkit.versions.v2022_11_28.models import (
ReposOwnerRepoHooksHookIdPatchBodyPropConfig as ReposOwnerRepoHooksHookIdPatchBodyPropConfig,
)
from githubkit.versions.v2022_11_28.models import (
ReposOwnerRepoImportAuthorsAuthorIdPatchBody as ReposOwnerRepoImportAuthorsAuthorIdPatchBody,
)
Expand Down Expand Up @@ -10706,6 +10708,7 @@
"CodeOfConductSimple",
"FullRepository",
"FullRepositoryPropPermissions",
"FullRepositoryPropCustomProperties",
"RepositoryRulesetBypassActor",
"RepositoryRulesetConditions",
"RepositoryRulesetConditionsPropRefName",
Expand Down Expand Up @@ -10990,7 +10993,6 @@
"GitTreePropTreeItems",
"HookResponse",
"Hook",
"HookPropConfig",
"Import",
"ImportPropProjectChoicesItems",
"PorterAuthor",
Expand Down Expand Up @@ -14018,7 +14020,6 @@
"ReposOwnerRepoHooksPostBody",
"ReposOwnerRepoHooksPostBodyPropConfig",
"ReposOwnerRepoHooksHookIdPatchBody",
"ReposOwnerRepoHooksHookIdPatchBodyPropConfig",
"ReposOwnerRepoHooksHookIdConfigPatchBody",
"ReposOwnerRepoImportPutBody",
"ReposOwnerRepoImportPatchBody",
Expand Down Expand Up @@ -14065,6 +14066,7 @@
"ReposOwnerRepoPagesPostBodyAnyof1",
"ReposOwnerRepoPagesDeploymentPostBody",
"ReposOwnerRepoProjectsPostBody",
"ReposOwnerRepoPropertiesValuesPatchBody",
"ReposOwnerRepoPullsPostBody",
"ReposOwnerRepoPullsCommentsCommentIdPatchBody",
"ReposOwnerRepoPullsCommentsCommentIdReactionsPostBody",
Expand Down
14 changes: 8 additions & 6 deletions githubkit/versions/latest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@
from githubkit.versions.v2022_11_28.models import ContentTraffic as ContentTraffic
from githubkit.versions.v2022_11_28.models import FullRepository as FullRepository
from githubkit.versions.v2022_11_28.models import GlobalAdvisory as GlobalAdvisory
from githubkit.versions.v2022_11_28.models import HookPropConfig as HookPropConfig
from githubkit.versions.v2022_11_28.models import LicenseContent as LicenseContent
from githubkit.versions.v2022_11_28.models import MergedUpstream as MergedUpstream
from githubkit.versions.v2022_11_28.models import PackageVersion as PackageVersion
Expand Down Expand Up @@ -2368,6 +2367,9 @@
from githubkit.versions.v2022_11_28.models import (
CodeScanningOrganizationAlertItems as CodeScanningOrganizationAlertItems,
)
from githubkit.versions.v2022_11_28.models import (
FullRepositoryPropCustomProperties as FullRepositoryPropCustomProperties,
)
from githubkit.versions.v2022_11_28.models import (
GistsGistIdGetResponse403PropBlock as GistsGistIdGetResponse403PropBlock,
)
Expand Down Expand Up @@ -3076,6 +3078,9 @@
from githubkit.versions.v2022_11_28.models import (
ReposOwnerRepoGitTagsPostBodyPropTagger as ReposOwnerRepoGitTagsPostBodyPropTagger,
)
from githubkit.versions.v2022_11_28.models import (
ReposOwnerRepoPropertiesValuesPatchBody as ReposOwnerRepoPropertiesValuesPatchBody,
)
from githubkit.versions.v2022_11_28.models import (
RepositoryRulePullRequestPropParameters as RepositoryRulePullRequestPropParameters,
)
Expand Down Expand Up @@ -3949,9 +3954,6 @@
from githubkit.versions.v2022_11_28.models import (
ReposOwnerRepoActionsWorkflowsGetResponse200 as ReposOwnerRepoActionsWorkflowsGetResponse200,
)
from githubkit.versions.v2022_11_28.models import (
ReposOwnerRepoHooksHookIdPatchBodyPropConfig as ReposOwnerRepoHooksHookIdPatchBodyPropConfig,
)
from githubkit.versions.v2022_11_28.models import (
ReposOwnerRepoImportAuthorsAuthorIdPatchBody as ReposOwnerRepoImportAuthorsAuthorIdPatchBody,
)
Expand Down Expand Up @@ -10706,6 +10708,7 @@
"CodeOfConductSimple",
"FullRepository",
"FullRepositoryPropPermissions",
"FullRepositoryPropCustomProperties",
"RepositoryRulesetBypassActor",
"RepositoryRulesetConditions",
"RepositoryRulesetConditionsPropRefName",
Expand Down Expand Up @@ -10990,7 +10993,6 @@
"GitTreePropTreeItems",
"HookResponse",
"Hook",
"HookPropConfig",
"Import",
"ImportPropProjectChoicesItems",
"PorterAuthor",
Expand Down Expand Up @@ -14018,7 +14020,6 @@
"ReposOwnerRepoHooksPostBody",
"ReposOwnerRepoHooksPostBodyPropConfig",
"ReposOwnerRepoHooksHookIdPatchBody",
"ReposOwnerRepoHooksHookIdPatchBodyPropConfig",
"ReposOwnerRepoHooksHookIdConfigPatchBody",
"ReposOwnerRepoImportPutBody",
"ReposOwnerRepoImportPatchBody",
Expand Down Expand Up @@ -14065,6 +14066,7 @@
"ReposOwnerRepoPagesPostBodyAnyof1",
"ReposOwnerRepoPagesDeploymentPostBody",
"ReposOwnerRepoProjectsPostBody",
"ReposOwnerRepoPropertiesValuesPatchBody",
"ReposOwnerRepoPullsPostBody",
"ReposOwnerRepoPullsCommentsCommentIdPatchBody",
"ReposOwnerRepoPullsCommentsCommentIdReactionsPostBody",
Expand Down
16 changes: 8 additions & 8 deletions githubkit/versions/latest/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@
from githubkit.versions.v2022_11_28.types import (
GlobalAdvisoryType as GlobalAdvisoryType,
)
from githubkit.versions.v2022_11_28.types import (
HookPropConfigType as HookPropConfigType,
)
from githubkit.versions.v2022_11_28.types import (
LicenseContentType as LicenseContentType,
)
Expand Down Expand Up @@ -2504,6 +2501,9 @@
from githubkit.versions.v2022_11_28.types import (
CodeScanningOrganizationAlertItemsType as CodeScanningOrganizationAlertItemsType,
)
from githubkit.versions.v2022_11_28.types import (
FullRepositoryPropCustomPropertiesType as FullRepositoryPropCustomPropertiesType,
)
from githubkit.versions.v2022_11_28.types import (
GistsGistIdGetResponse403PropBlockType as GistsGistIdGetResponse403PropBlockType,
)
Expand Down Expand Up @@ -3212,6 +3212,9 @@
from githubkit.versions.v2022_11_28.types import (
ReposOwnerRepoGitTagsPostBodyPropTaggerType as ReposOwnerRepoGitTagsPostBodyPropTaggerType,
)
from githubkit.versions.v2022_11_28.types import (
ReposOwnerRepoPropertiesValuesPatchBodyType as ReposOwnerRepoPropertiesValuesPatchBodyType,
)
from githubkit.versions.v2022_11_28.types import (
RepositoryRulePullRequestPropParametersType as RepositoryRulePullRequestPropParametersType,
)
Expand Down Expand Up @@ -4085,9 +4088,6 @@
from githubkit.versions.v2022_11_28.types import (
ReposOwnerRepoActionsWorkflowsGetResponse200Type as ReposOwnerRepoActionsWorkflowsGetResponse200Type,
)
from githubkit.versions.v2022_11_28.types import (
ReposOwnerRepoHooksHookIdPatchBodyPropConfigType as ReposOwnerRepoHooksHookIdPatchBodyPropConfigType,
)
from githubkit.versions.v2022_11_28.types import (
ReposOwnerRepoImportAuthorsAuthorIdPatchBodyType as ReposOwnerRepoImportAuthorsAuthorIdPatchBodyType,
)
Expand Down Expand Up @@ -10842,6 +10842,7 @@
"CodeOfConductSimpleType",
"FullRepositoryType",
"FullRepositoryPropPermissionsType",
"FullRepositoryPropCustomPropertiesType",
"RepositoryRulesetBypassActorType",
"RepositoryRulesetConditionsType",
"RepositoryRulesetConditionsPropRefNameType",
Expand Down Expand Up @@ -11126,7 +11127,6 @@
"GitTreePropTreeItemsType",
"HookResponseType",
"HookType",
"HookPropConfigType",
"ImportType",
"ImportPropProjectChoicesItemsType",
"PorterAuthorType",
Expand Down Expand Up @@ -14154,7 +14154,6 @@
"ReposOwnerRepoHooksPostBodyType",
"ReposOwnerRepoHooksPostBodyPropConfigType",
"ReposOwnerRepoHooksHookIdPatchBodyType",
"ReposOwnerRepoHooksHookIdPatchBodyPropConfigType",
"ReposOwnerRepoHooksHookIdConfigPatchBodyType",
"ReposOwnerRepoImportPutBodyType",
"ReposOwnerRepoImportPatchBodyType",
Expand Down Expand Up @@ -14201,6 +14200,7 @@
"ReposOwnerRepoPagesPostBodyAnyof1Type",
"ReposOwnerRepoPagesDeploymentPostBodyType",
"ReposOwnerRepoProjectsPostBodyType",
"ReposOwnerRepoPropertiesValuesPatchBodyType",
"ReposOwnerRepoPullsPostBodyType",
"ReposOwnerRepoPullsCommentsCommentIdPatchBodyType",
"ReposOwnerRepoPullsCommentsCommentIdReactionsPostBodyType",
Expand Down
Loading