-
Notifications
You must be signed in to change notification settings - Fork 2
API documentation with Sphinx configuration and workflows #154
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
Open
marcos-sinch
wants to merge
12
commits into
v2.1-next
Choose a base branch
from
feature/DEVEXP-831-generate-online-documentation
base: v2.1-next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
57d9e58
feat(docs): add Sphinx configuration and index for API documentation
marcos-sinch ffbbf89
feat(docs): add docs requirements to requirements-dev
marcos-sinch 5f4809f
feat(docs): remove pin for sphinx dev dependency
marcos-sinch 563102f
feat(docs): add push documentation workflow
marcos-sinch dafdd17
feat(docs): add push documentation workflow
marcos-sinch 5070abc
feat(docs): add version validation
marcos-sinch a124798
feat(docs): enhance documentation generation and styling
marcos-sinch f10c546
feat(docs): update documentation templates and add new init file
marcos-sinch 0c20c02
feat(docs): remove documentation generation step from CI workflow
marcos-sinch 5b24b47
fix(docs): update copyright year in project information
marcos-sinch d5d7bab
feat(docs): add documentation generation step to CI workflow
marcos-sinch 409f89f
feat(docs): add missing __init__.py file for message models in conver…
marcos-sinch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| name: Generate and upload documentation | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'Version to use for the documentation package in semver format (e.g. 1.2.3)' | ||
| required: true | ||
|
|
||
| jobs: | ||
| upload-documentation: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| SDK_NAME: sinch-sdk-python | ||
|
|
||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Resolve Version | ||
| id: version | ||
| run: | | ||
| if [ "${{ github.event_name }}" = "release" ]; then | ||
| VERSION="${{ github.event.release.tag_name }}" | ||
| else | ||
| VERSION="${{ inputs.version }}" | ||
| fi | ||
| # Strip leading 'v' if present (e.g. v1.2.3 → 1.2.3) | ||
| VERSION="${VERSION#v}" | ||
| echo "value=${VERSION}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Validate Version Format | ||
| run: | | ||
| VERSION="${{ steps.version.outputs.value }}" | ||
| SEMVER_REGEX='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((alpha|beta|preview)(\.[0-9]+)?))?$' | ||
| if [[ ! "$VERSION" =~ $SEMVER_REGEX ]]; then | ||
| echo "::error::Invalid version format: '$VERSION'. Expected semver (e.g. 1.2.3, 1.2.3-alpha, 1.2.3-beta.1, 1.2.3-preview)" | ||
| exit 1 | ||
| fi | ||
| echo "Version '$VERSION' is valid" | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Install dev dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements-dev.txt | ||
|
|
||
| - name: Generate Documentation | ||
| run: | | ||
| make docs | ||
|
|
||
| - name: Package Documentation | ||
| run: | | ||
| cd docs/build/html | ||
| zip -r "../../../${{ env.SDK_NAME }}-${{ steps.version.outputs.value }}.zip" . | ||
|
|
||
| - name: Upload to GitLab Registry | ||
| run: | | ||
| echo "Uploading documentation package to GitLab Registry..." | ||
| VERSION="${{ steps.version.outputs.value }}" | ||
| curl --fail --show-error --location --header "PRIVATE-TOKEN: ${{ secrets.GITLAB_REGISTRY_UPLOAD_DOC_TOKEN }}" \ | ||
| --upload-file "./${{ env.SDK_NAME }}-${VERSION}.zip" \ | ||
| "https://gitlab.com/api/v4/projects/63164411/packages/generic/${{ env.SDK_NAME }}/${VERSION}/${{ env.SDK_NAME }}-${VERSION}.zip" | ||
| echo "Documentation package for version ${VERSION} uploaded to GitLab Registry" | ||
|
|
||
| - name: Trigger Downstream GitLab Pipeline | ||
| run: | | ||
| echo "Triggering downstream GitLab pipeline to notify about new documentation package version..." | ||
| VERSION="${{ steps.version.outputs.value }}" | ||
| curl --fail --show-error --location --request POST \ | ||
| --form "token=${{ secrets.GITLAB_NOTIFY_REGISTRY_UPLOADED_DOC_TOKEN }}" \ | ||
| --form "ref=main" \ | ||
| --form "variables[UPSTREAM_PACKAGE_NAME]=${{ env.SDK_NAME }}" \ | ||
| --form "variables[UPSTREAM_PACKAGE_VERSION]=${VERSION}" \ | ||
| "https://gitlab.com/api/v4/projects/63164411/trigger/pipeline" | ||
| echo "Documentation repo notified about new package version ${VERSION}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,7 +73,9 @@ instance/ | |
| .scrapy | ||
|
|
||
| # Sphinx documentation | ||
| docs/_build/ | ||
| docs/build/ | ||
| docs/api/ | ||
|
|
||
|
|
||
| # PyBuilder | ||
| .pybuilder/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .PHONY: docs | ||
|
|
||
| docs: | ||
| rm -rf docs/build | ||
| rm -rf docs/api | ||
| sphinx-apidoc --force --separate --no-toc --maxdepth 2 --templatedir docs/_templates/apidoc -o docs/api sinch | ||
| sphinx-build -b html docs docs/build/html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* --------------------------------------------------------------------------- | ||
| Multi-line signatures (one parameter per line). | ||
|
|
||
| When a signature is wrapped, Sphinx renders each parameter as a <dd> inside | ||
| a nested <dl>. The Read the Docs theme styles every <dl>/<dd> with borders, | ||
| background tint and vertical margins, which leak into the signature and draw | ||
| ugly "lines" between parameters. Flatten that nested list so the parameters | ||
| read as a clean indented column. | ||
| --------------------------------------------------------------------------- */ | ||
| .rst-content .sig dl, | ||
| .rst-content .sig dd { | ||
| margin: 0; | ||
| padding: 0; | ||
| border: none; | ||
| background: none; | ||
| } | ||
|
|
||
| /* Keep each parameter indented under the opening parenthesis. */ | ||
| .rst-content .sig dd { | ||
| margin-left: 2em; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| {%- if show_headings %} | ||
| {{- [basename, "module"] | join(" ") | e | heading }} | ||
|
|
||
| {% endif -%} | ||
| .. automodule:: {{ qualname }} | ||
| {%- for option in automodule_options %} | ||
| :{{ option }}: | ||
| {%- endfor %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| {%- macro automodule(modname, options) -%} | ||
| .. automodule:: {{ modname }} | ||
| {%- for option in options %} | ||
| :{{ option }}: | ||
| {%- endfor %} | ||
| {%- endmacro %} | ||
|
|
||
| {%- macro toctree(docnames) -%} | ||
| .. toctree:: | ||
| :maxdepth: {{ maxdepth }} | ||
| {% for docname in docnames %} | ||
| {{ docname }} | ||
| {%- endfor %} | ||
| {%- endmacro %} | ||
|
|
||
| {{- [pkgname, "package"] | join(" ") | e | heading }} | ||
|
|
||
| {%- if is_namespace %} | ||
| .. py:module:: {{ pkgname }} | ||
| {% endif %} | ||
|
|
||
| {%- if subpackages %} | ||
| {{ toctree(subpackages) }} | ||
| {% endif %} | ||
|
|
||
| {%- if submodules %} | ||
| {% if separatemodules %} | ||
| {{ toctree(submodules) }} | ||
| {% else %} | ||
| {% for submodule in submodules %} | ||
| {{ [submodule.split(".")[-1], "module"] | join(" ") | e | heading(2) }} | ||
| {{ automodule(submodule, automodule_options) }} | ||
| {% endfor %} | ||
| {%- endif %} | ||
| {%- endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import os | ||
| import sys | ||
|
|
||
| # Allow autodoc to import the sinch package from the project root | ||
| sys.path.insert(0, os.path.abspath("..")) | ||
| from sinch import __version__ | ||
|
|
||
| # -- Project information ------------------------------------------------------- | ||
|
|
||
| project = "Sinch Python SDK" | ||
| copyright = "2026, Sinch Developer Experience Team" | ||
| author = "Sinch Developer Experience Team" | ||
| release = __version__ | ||
|
|
||
| # -- General configuration ----------------------------------------------------- | ||
|
|
||
| extensions = [ | ||
| # Pulls docstrings from Python source into the generated .rst files | ||
| "sphinx.ext.autodoc", | ||
| # Adds [source] links that open the highlighted source file | ||
| "sphinx.ext.viewcode", | ||
| ] | ||
|
|
||
| # The .rst files under api/ are generated by the `sphinx-apidoc` CLI invoked | ||
| # from the Makefile (`make docs`), using the custom templates in | ||
| # _templates/apidoc/ to strip the "package" suffix and the | ||
| # "Subpackages"/"Submodules"/"Module contents" headings. The | ||
| # sphinx.ext.apidoc extension is intentionally NOT used because it ignores | ||
| # the template directory. | ||
|
|
||
| # -- sphinx.ext.autodoc -------------------------------------------------------- | ||
|
|
||
| autodoc_default_options = { | ||
| # Document all public members (methods, attributes, nested classes) | ||
| "members": True, | ||
| 'undoc-members': True, | ||
| # Show the class inheritance chain | ||
| "show-inheritance": True, | ||
| # Preserve the order in which members appear in the source file | ||
| "member-order": "bysource", | ||
| } | ||
|
|
||
| # Render type hints as part of the parameter/return descriptions, not the signature | ||
| autodoc_typehints = "both" | ||
| python_maximum_signature_line_length = 88 | ||
|
|
||
| # -- HTML output --------------------------------------------------------------- | ||
|
|
||
| html_theme = "sphinx_rtd_theme" | ||
|
|
||
| html_theme_options = { | ||
| # Maximum depth of the navigation sidebar (-1 = unlimited) | ||
| "navigation_depth": -1, | ||
| # Keep all navigation entries expanded by default | ||
| "collapse_navigation": False, | ||
| } | ||
|
|
||
| # Directory with extra static files (custom CSS, etc.), relative to this conf.py | ||
| html_static_path = ["_static"] | ||
|
|
||
| # Extra stylesheets loaded after the theme's own CSS | ||
| html_css_files = ["custom.css"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| Sinch Python SDK | ||
| ================ | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 3 | ||
| :caption: API Reference | ||
|
|
||
| api/sinch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.