Skip to content

feat(docs): generate doc #823

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
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 2 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,13 @@ jobs:
poetry --version
- name: Install dependencies and library
run: poetry install --no-root
- name: Generate documentation sources
run: |
poetry run sphinx-apidoc -f -o ./source ../scaleway-core
poetry run sphinx-apidoc -f -o ./source ../scaleway
poetry run sphinx-apidoc -f -o ./source ../scaleway-async
- name: Generate documentation
run: poetry run sphinx-build -b html ./ ./_build
run: poetry run make html
Copy link
Member

Choose a reason for hiding this comment

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

please add a -j auto flag to sphinx-docs build because it is really slow otherwise

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
publish_branch: docs
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build
force_orphan: true
force_orphan: true
2 changes: 0 additions & 2 deletions docs/.gitignore

This file was deleted.

Empty file removed docs/_static/.gitkeep
Empty file.
Empty file removed docs/_templates/.gitkeep
Empty file.
13 changes: 13 additions & 0 deletions docs/_templates/autoapi/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
API Reference
=============

This page contains auto-generated API reference documentation [#f1]_.

.. toctree::
:titlesonly:

{% for page in pages|selectattr("is_top_level_object") %}
{{ page.include_path }}
{% endfor %}

.. [#f1] Created with `sphinx-autoapi <https://github.com/readthedocs/sphinx-autoapi>`_
12 changes: 12 additions & 0 deletions docs/_templates/autoapi/macros.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% import 'macros.rst' as macros %}
{% macro auto_summary(objs, title='') -%}

.. list-table:: {{ title }}
:header-rows: 0
:widths: auto

{% for obj in objs %}
* - obj.name
- obj.summary
{% endfor %}
{% endmacro %}
1 change: 1 addition & 0 deletions docs/_templates/autoapi/python/attribute.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends "python/data.rst" %}
104 changes: 104 additions & 0 deletions docs/_templates/autoapi/python/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{% if obj.display %}
{% if is_own_page %}
{{ obj.id }}
{{ "=" * obj.id | length }}

{% endif %}
{% set visible_children = obj.children|selectattr("display")|list %}
{% set own_page_children = visible_children|selectattr("type", "in", own_page_types)|list %}
{% if is_own_page and own_page_children %}
.. toctree::
:hidden:

{% for child in own_page_children %}
{{ child.include_path }}
{% endfor %}

{% endif %}
.. py:{{ obj.type }}:: {% if is_own_page %}{{ obj.id }}{% else %}{{ obj.short_name }}{% endif %}{% if obj.args %}({{ obj.args }}){% endif %}

{% for (args, return_annotation) in obj.overloads %}
{{ " " * (obj.type | length) }} {{ obj.short_name }}{% if args %}({{ args }}){% endif %}

{% endfor %}
{% if obj.bases %}
{% if "show-inheritance" in autoapi_options %}

Bases: {% for base in obj.bases %}{{ base|link_objs }}{% if not loop.last %}, {% endif %}{% endfor %}
{% endif %}


{% if "show-inheritance-diagram" in autoapi_options and obj.bases != ["object"] %}
.. autoapi-inheritance-diagram:: {{ obj.obj["full_name"] }}
:parts: 1
{% if "private-members" in autoapi_options %}
:private-bases:
{% endif %}

{% endif %}
{% endif %}
{% if obj.docstring %}

{{ obj.docstring|indent(3) }}
{% endif %}
{% for obj_item in visible_children %}
{% if obj_item.type not in own_page_types %}

{{ obj_item.render()|indent(3) }}
{% endif %}
{% endfor %}
{% if is_own_page and own_page_children %}
{% set visible_attributes = own_page_children|selectattr("type", "equalto", "attribute")|list %}
{% if visible_attributes %}
Attributes
----------

.. autoapisummary::

{% for attribute in visible_attributes %}
{{ attribute.id }}
{% endfor %}


{% endif %}
{% set visible_exceptions = own_page_children|selectattr("type", "equalto", "exception")|list %}
{% if visible_exceptions %}
Exceptions
----------

.. autoapisummary::

{% for exception in visible_exceptions %}
{{ exception.id }}
{% endfor %}


{% endif %}
{% set visible_classes = own_page_children|selectattr("type", "equalto", "class")|list %}
{% if visible_classes %}
Classes
-------

.. autoapisummary::

{% for klass in visible_classes %}
{{ klass.id }}
{% endfor %}


{% endif %}
{% set visible_methods = own_page_children|selectattr("type", "equalto", "method")|list %}
{% if visible_methods %}
Methods
-------

.. autoapisummary::

{% for method in visible_methods %}
{{ method.id }}
{% endfor %}


{% endif %}
{% endif %}
{% endif %}
38 changes: 38 additions & 0 deletions docs/_templates/autoapi/python/data.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% if obj.display %}
{% if is_own_page %}
{{ obj.id }}
{{ "=" * obj.id | length }}

{% endif %}
.. py:{{ obj.type }}:: {% if is_own_page %}{{ obj.id }}{% else %}{{ obj.name }}{% endif %}
{% if obj.annotation is not none %}

:type: {% if obj.annotation %} {{ obj.annotation }}{% endif %}
{% endif %}
{% if obj.value is not none %}

{% if obj.value.splitlines()|count > 1 %}
:value: Multiline-String

.. raw:: html

<details><summary>Show Value</summary>

.. code-block:: python

{{ obj.value|indent(width=6,blank=true) }}

.. raw:: html

</details>

{% else %}
:value: {{ obj.value|truncate(100) }}
{% endif %}
{% endif %}

{% if obj.docstring %}

{{ obj.docstring|indent(3) }}
{% endif %}
{% endif %}
1 change: 1 addition & 0 deletions docs/_templates/autoapi/python/exception.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends "python/class.rst" %}
21 changes: 21 additions & 0 deletions docs/_templates/autoapi/python/function.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% if obj.display %}
{% if is_own_page %}
{{ obj.id }}
{{ "=" * obj.id | length }}

{% endif %}
.. py:function:: {% if is_own_page %}{{ obj.id }}{% else %}{{ obj.short_name }}{% endif %}({{ obj.args }}){% if obj.return_annotation is not none %} -> {{ obj.return_annotation }}{% endif %}
{% for (args, return_annotation) in obj.overloads %}

{%+ if is_own_page %}{{ obj.id }}{% else %}{{ obj.short_name }}{% endif %}({{ args }}){% if return_annotation is not none %} -> {{ return_annotation }}{% endif %}
{% endfor %}
{% for property in obj.properties %}

:{{ property }}:
{% endfor %}

{% if obj.docstring %}

{{ obj.docstring|indent(3) }}
{% endif %}
{% endif %}
21 changes: 21 additions & 0 deletions docs/_templates/autoapi/python/method.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% if obj.display %}
{% if is_own_page %}
{{ obj.id }}
{{ "=" * obj.id | length }}

{% endif %}
.. py:method:: {% if is_own_page %}{{ obj.id }}{% else %}{{ obj.short_name }}{% endif %}({{ obj.args }}){% if obj.return_annotation is not none %} -> {{ obj.return_annotation }}{% endif %}
{% for (args, return_annotation) in obj.overloads %}

{%+ if is_own_page %}{{ obj.id }}{% else %}{{ obj.short_name }}{% endif %}({{ args }}){% if return_annotation is not none %} -> {{ return_annotation }}{% endif %}
{% endfor %}
{% for property in obj.properties %}

:{{ property }}:
{% endfor %}

{% if obj.docstring %}

{{ obj.docstring|indent(3) }}
{% endif %}
{% endif %}
Loading