Skip to content
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

Ditch swagger2rst dependency #323

Merged
merged 4 commits into from
Jan 10, 2024
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
12 changes: 5 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.ifconfig',
'sphinxcontrib.openapi',
]

# A list of warning types to suppress arbitrary warning messages.
Expand Down Expand Up @@ -488,30 +489,27 @@

def on_init(app): # pylint: disable=unused-argument
"""
Run sphinx-apidoc and swg2rst after Sphinx initialization.
Run sphinx-apidoc after Sphinx initialization.

Read the Docs won't run tox or custom shell commands, so we need this to
avoid checking in the generated reStructuredText files.
"""
docs_path = os.path.abspath(os.path.dirname(__file__))
root_path = os.path.abspath(os.path.join(docs_path, '..'))
apidoc_path = 'sphinx-apidoc'
swg2rst_path = 'swg2rst'

if hasattr(sys, 'real_prefix'): # Check to see if we are in a virtualenv
# If we are, assemble the path manually
bin_path = os.path.abspath(os.path.join(sys.prefix, 'bin'))
apidoc_path = os.path.join(bin_path, apidoc_path)
swg2rst_path = os.path.join(bin_path, swg2rst_path)

check_call([apidoc_path, '-o', docs_path, os.path.join(root_path, 'user_tasks'),
os.path.join(root_path, 'user_tasks/migrations')])
json_path = os.path.join(docs_path, 'swagger.json')
rst_path = os.path.join(docs_path, 'rest_api.rst')
check_call([swg2rst_path, json_path, '-f', 'rst', '-o', rst_path])


def setup(app):
"""
Sphinx extension: run sphinx-apidoc and swg2rst.
Sphinx extension: run sphinx-apidoc.
"""
event = 'builder-inited'
app.connect(event, on_init)
2 changes: 2 additions & 0 deletions docs/readme.rst
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.. include:: ../README.rst

.. openapi:: swagger.json
6 changes: 2 additions & 4 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ pytz==2023.3.post1
# django
# djangorestframework
# drf-yasg
pyyaml==5.4.1
# via
# -c requirements/constraints.txt
# drf-yasg
pyyaml==6.0.1
# via drf-yasg
six==1.16.0
# via python-dateutil
sqlparse==0.4.4
Expand Down
5 changes: 0 additions & 5 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,3 @@
-c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt

celery<6.0

# pyyaml==6.0 made the `Loader` a necessary argument for `yaml.load()` function.
# swagger2rst uses pyyaml and fails with the new version hence failing the `make docs` command.
# This constraint can be removed once the https://github.com/Arello-Mobile/swagger2rst/issues/10 is done.
pyyaml<6.0
3 changes: 1 addition & 2 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,8 @@ pytz==2023.3.post1
# django
# djangorestframework
# drf-yasg
pyyaml==5.4.1
pyyaml==6.0.1
# via
# -c requirements/constraints.txt
# -r requirements/quality.txt
# -r requirements/test.txt
# code-annotations
Expand Down
2 changes: 1 addition & 1 deletion requirements/doc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ doc8 # reStructuredText style checker
sphinx-book-theme # Common theme for all Open edX projects
rules # Needed to import user_tasks/rules.py for autodoc
Sphinx # Documentation builder
swagger2rst # Generates REST API documentation for Sphinx from a Swagger/Open API schema JSON file
sphinxcontrib-openapi
twine # Validates the generated long description for PyPI
31 changes: 20 additions & 11 deletions requirements/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ billiard==4.2.0
# via
# -r requirements/base.txt
# celery
cached-property==1.5.2
# via swagger2rst
celery==5.3.6
# via
# -c requirements/constraints.txt
Expand Down Expand Up @@ -73,6 +71,8 @@ coreapi==2.3.3
# openapi-codec
coreschema==0.0.4
# via coreapi
deepmerge==1.1.0
# via sphinxcontrib-openapi
cryptography==41.0.7
# via secretstorage
django==3.2.23
Expand Down Expand Up @@ -100,6 +100,7 @@ docutils==0.19
# readme-renderer
# restructuredtext-lint
# sphinx
# sphinx-mdinclude
drf-yasg==1.21.7
# via -r requirements/base.txt
idna==3.6
Expand Down Expand Up @@ -132,9 +133,8 @@ jinja2==3.1.2
# via
# coreschema
# sphinx
# swagger2rst
jsonschema==4.20.0
# via swagger2rst
# via sphinxcontrib-openapi
jsonschema-specifications==2023.11.2
# via jsonschema
keyring==24.3.0
Expand All @@ -149,6 +149,8 @@ markupsafe==2.1.3
# via jinja2
mdurl==0.1.2
# via markdown-it-py
mistune==2.0.5
# via sphinx-mdinclude
more-itertools==10.1.0
# via jaraco-classes
nh3==0.2.15
Expand All @@ -163,6 +165,8 @@ packaging==23.2
# sphinx
pbr==6.0.0
# via stevedore
picobox==4.0.0
# via sphinxcontrib-openapi
pkginfo==1.9.6
# via twine
pkgutil-resolve-name==1.3.10
Expand All @@ -183,6 +187,7 @@ pygments==2.17.2
# readme-renderer
# rich
# sphinx
# sphinx-mdinclude
python-dateutil==2.8.2
# via
# -r requirements/base.txt
Expand All @@ -194,12 +199,11 @@ pytz==2023.3.post1
# django
# djangorestframework
# drf-yasg
pyyaml==5.4.1
pyyaml==6.0.1
# via
# -c requirements/constraints.txt
# -r requirements/base.txt
# drf-yasg
# swagger2rst
# sphinxcontrib-openapi
readme-renderer==42.0
# via twine
referencing==0.32.0
Expand Down Expand Up @@ -234,6 +238,7 @@ six==1.16.0
# via
# -r requirements/base.txt
# python-dateutil
# sphinxcontrib-httpdomain
snowballstemmer==2.2.0
# via sphinx
soupsieve==2.5
Expand All @@ -243,16 +248,24 @@ sphinx==6.2.1
# -r requirements/doc.in
# pydata-sphinx-theme
# sphinx-book-theme
# sphinxcontrib-httpdomain
# sphinxcontrib-openapi
sphinx-book-theme==1.0.1
# via -r requirements/doc.in
sphinx-mdinclude==0.5.3
# via sphinxcontrib-openapi
sphinxcontrib-applehelp==1.0.4
# via sphinx
sphinxcontrib-devhelp==1.0.2
# via sphinx
sphinxcontrib-htmlhelp==2.0.1
# via sphinx
sphinxcontrib-httpdomain==1.8.1
# via sphinxcontrib-openapi
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-openapi==0.8.3
# via -r requirements/doc.in
sphinxcontrib-qthelp==1.0.3
# via sphinx
sphinxcontrib-serializinghtml==1.1.5
Expand All @@ -263,10 +276,6 @@ sqlparse==0.4.4
# django
stevedore==5.1.0
# via doc8
strict-rfc3339==0.7
# via swagger2rst
swagger2rst==0.0.4
# via -r requirements/doc.in
tomli==2.0.1
# via doc8
twine==4.0.2
Expand Down
6 changes: 2 additions & 4 deletions requirements/quality.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ pylint-plugin-utils==0.8.2
# pylint-django
python-slugify==8.0.1
# via code-annotations
pyyaml==5.4.1
# via
# -c requirements/constraints.txt
# code-annotations
pyyaml==6.0.1
# via code-annotations
six==1.16.0
# via edx-lint
snowballstemmer==2.2.0
Expand Down
3 changes: 1 addition & 2 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ pytz==2023.3.post1
# django
# djangorestframework
# drf-yasg
pyyaml==5.4.1
pyyaml==6.0.1
# via
# -c requirements/constraints.txt
# -r requirements/base.txt
# drf-yasg
rules==3.3
Expand Down