diff --git a/Makefile b/Makefile index 82ed11a..b7949de 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ quality-python: ## Run python linters tox -e quality quality-rst: ## validate rst files - rstcheck -r --report-level warning . + rstcheck -r --report-level warning --ignore-directives=toctree --ignore-roles=ref . quality: quality-python quality-rst ## Run linters diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d4bb2cb --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/conf.py b/docs/conf.py index dd7eab9..f28efab 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,499 +1,67 @@ -# pylint: disable=invalid-name -""" -edx_name_affirmation documentation build configuration file. - -This file is execfile()d with the current directory set to its -containing dir. +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html -Note that not all possible configuration values are present in this -autogenerated file. +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -All configuration values have a default; values that are commented out -serve to show the default. -""" import os -import re -import sys -from subprocess import check_call - -import edx_theme -from django import setup as django_setup - - -def get_version(*file_paths): - """ - Extract the version string from the file at the given relative path fragments. - """ - filename = os.path.join(os.path.dirname(__file__), *file_paths) - version_file = open(filename).read() - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) - if version_match: - return version_match.group(1) - raise RuntimeError('Unable to find version string.') - - -REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -sys.path.append(REPO_ROOT) - -VERSION = get_version('../edx_name_affirmation', '__init__.py') - -# Configure Django for autodoc usage -os.environ['DJANGO_SETTINGS_MODULE'] = 'test_settings' -django_setup() +from datetime import datetime -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' +project = 'edx-name-affirmation' +copyright = f'{datetime.now().year}, edX LLC.' # pylint: disable=redefined-builtin +author = 'edX LLC' +release = '2.3.7' -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'edx_theme', - 'sphinx.ext.autodoc', - 'sphinx.ext.doctest', - 'sphinx.ext.intersphinx', - 'sphinx.ext.ifconfig', - 'sphinx.ext.napoleon' -] +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration -# A list of warning types to suppress arbitrary warning messages. -suppress_warnings = [ - 'image.nonlocal_uri', -] +extensions = [] -# Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The encoding of source files. -# -# source_encoding = 'utf-8-sig' - -# The top level toctree document. -top_level_doc = 'index' - -# General information about the project. -project = 'edx_name_affirmation' -copyright = edx_theme.COPYRIGHT # pylint: disable=redefined-builtin -author = edx_theme.AUTHOR -project_title = 'edx-name-affimation' -documentation_title = f"{project_title}" - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = VERSION -# The full version, including alpha/beta/rc tags. -release = VERSION - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# -# today = '' -# -# Else, today_fmt is used as the format for a strftime call. -# -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This patterns also effect to html_static_path and html_extra_path exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] -# The reST default role (used for this markup: `text`) to use for all -# documents. -# -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = False - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. - -html_theme = 'edx_theme' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -html_theme_path = [edx_theme.get_html_theme_path()] - -# The name for this set of Sphinx documents. -# " v documentation" by default. -# -# html_title = 'edx_name_affirmation v0.1.0' - -# A shorter title for the navigation bar. Default is the same as html_title. -# -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# -# html_logo = None - -# The name of an image file (relative to this directory) to use as a favicon of -# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# -# html_extra_path = [] - -# If not None, a 'Last updated on:' timestamp is inserted at every page -# bottom, using the given strftime format. -# The empty string is equivalent to '%b %d, %Y'. -# -# html_last_updated_fmt = None - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# -# html_additional_pages = {} - -# If false, no module index is generated. -# -# html_domain_indices = True - -# If false, no index is generated. -# -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr', 'zh' -# -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# 'ja' uses this config value. -# 'zh' user can custom change `jieba` dictionary path. -# -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = f'{project}doc' - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_target = f'{project}.tex' -latex_documents = [ - (top_level_doc, latex_target, documentation_title, - author, 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# -# latex_use_parts = False - -# If true, show page references after internal links. -# -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# -# latex_appendices = [] - -# It false, will not define \strong, \code, itleref, \crossref ... but only -# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added -# packages. -# -# latex_keep_old_macro_names = True - -# If false, no module index is generated. -# -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (top_level_doc, project_title, documentation_title, - [author], 1) -] - -# If true, show URL addresses after external links. -# -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (top_level_doc, project_title, documentation_title, - author, project_title, 'Django app housing name affirmation logic', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -# -# texinfo_appendices = [] - -# If false, no module index is generated. -# -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# -# texinfo_no_detailmenu = False - - -# -- Options for Epub output ---------------------------------------------- - -# Bibliographic Dublin Core info. -epub_title = project -epub_author = author -epub_publisher = author -epub_copyright = copyright - -# The basename for the epub file. It defaults to the project name. -# epub_basename = project - -# The HTML theme for the epub output. Since the default themes are not -# optimized for small screen space, using the same theme for HTML and epub -# output is usually not wise. This defaults to 'epub', a theme designed to save -# visual space. -# -# epub_theme = 'epub' - -# The language of the text. It defaults to the language option -# or 'en' if the language is not set. -# -# epub_language = '' - -# The scheme of the identifier. Typical schemes are ISBN or URL. -# epub_scheme = '' - -# The unique identifier of the text. This can be a ISBN number -# or the project homepage. -# -# epub_identifier = '' - -# A unique identification for the text. -# -# epub_uid = '' - -# A tuple containing the cover image and cover page html template filenames. -# -# epub_cover = () - -# A sequence of (type, uri, title) tuples for the guide element of content.opf. -# -# epub_guide = () - -# HTML files that should be inserted before the pages created by sphinx. -# The format is a list of tuples containing the path and title. -# -# epub_pre_files = [] - -# HTML files that should be inserted after the pages created by sphinx. -# The format is a list of tuples containing the path and title. -# -# epub_post_files = [] - -# A list of files that should not be packed into the epub file. -epub_exclude_files = ['search.html'] - -# The depth of the table of contents in toc.ncx. -# -# epub_tocdepth = 3 - -# Allow duplicate toc entries. -# -# epub_tocdup = True - -# Choose between 'default' and 'includehidden'. -# -# epub_tocscope = 'default' - -# Fix unsupported image types using the Pillow. -# -# epub_fix_images = False - -# Scale large images. -# -# epub_max_image_width = 0 - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# -# epub_show_urls = 'inline' - -# If false, no index is generated. -# -# epub_use_index = True - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - 'python': ('https://docs.python.org/3.11', None), - 'django': ('https://docs.djangoproject.com/en/2.2/', 'https://docs.djangoproject.com/en/2.2/_objects/'), - 'model_utils': ('https://django-model-utils.readthedocs.io/en/latest/', None), -} - - -def on_init(app): # pylint: disable=unused-argument +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = "sphinx_book_theme" + +html_theme_options = { + "repository_url": "https://github.com/edx/edx-name-affirmation", + "repository_branch": 'main', + "path_to_docs": "docs/", + "use_repository_button": True, + "use_issues_button": True, + "use_edit_page_button": True, + # Please don't change unless you know what you're doing. + "extra_footer": """ + + Creative Commons License + +
+ These works by + edX LLC + are licensed under a + Creative Commons Attribution-ShareAlike 4.0 International License. """ - 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' - 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) - check_call([apidoc_path, '-o', docs_path, os.path.join(root_path, 'edx_name_affirmation'), - os.path.join(root_path, 'edx_name_affirmation/migrations')]) +html_logo = "https://logos.openedx.org/open-edx-logo-color.png" +html_favicon = "https://logos.openedx.org/open-edx-favicon.ico" +if not os.environ.get('DJANGO_SETTINGS_MODULE'): + os.environ['DJANGO_SETTINGS_MODULE'] = 'test_utils.test_settings' -def setup(app): - """Sphinx extension: run sphinx-apidoc.""" - event = 'builder-inited' - app.connect(event, on_init) +html_static_path = ['_static'] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..05461b9 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,19 @@ +.. edx-name-affirmation documentation master file, created by + sphinx-quickstart on Tue Jul 30 15:21:12 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to edx-name-affirmation's documentation! +================================================ + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..32bb245 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/edx_name_affirmation/api.py b/edx_name_affirmation/api.py index 0ddf303..3176e58 100644 --- a/edx_name_affirmation/api.py +++ b/edx_name_affirmation/api.py @@ -214,6 +214,7 @@ def update_verified_name_status( def create_verified_name_config(user, use_verified_name_for_certs=None): """ Create verified name configuration for the given user. + Arguments: * `user` (User object) * `use_verified_name_for_certs` (bool): If True, certificates will prioritize diff --git a/edx_name_affirmation/views.py b/edx_name_affirmation/views.py index 36e21ef..519000e 100644 --- a/edx_name_affirmation/views.py +++ b/edx_name_affirmation/views.py @@ -1,6 +1,7 @@ """ Name Affirmation HTTP-based API endpoints """ + from edx_api_doc_tools import path_parameter, query_parameter, schema from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication from rest_framework import status as http_status @@ -34,9 +35,11 @@ class AuthenticatedAPIView(APIView): + """ Authenticate API View. """ + authentication_classes = (SessionAuthentication, JwtAuthentication) permission_classes = (IsAuthenticated,) @@ -65,6 +68,7 @@ def get(self, request): """ Get most recent verified name for the request user or for the specified username For example: /edx_name_affirmation/v1/verified_name?username=jdoe + Example response: { "username": "jdoe", "verified_name": "Jonathan Doe", @@ -105,6 +109,7 @@ def get(self, request): def post(self, request): """ Creates a new VerifiedName. + Expected POST data: { "username": "jdoe", "verified_name": "Jonathan Doe" @@ -156,6 +161,7 @@ def post(self, request): def patch(self, request): """ Update verified name status + Example PATCH data: { "username": "jdoe", "verification_attempt_id" OR "proctored_exam_attempt_id": 123, @@ -276,6 +282,7 @@ class VerifiedNameConfigView(AuthenticatedAPIView): HTTP POST Creates a new VerifiedName. + Example POST data: { "username": "jdoe", "use_verified_name_for_certs": True diff --git a/requirements/doc.in b/requirements/doc.in index 99968d3..9b5b7aa 100644 --- a/requirements/doc.in +++ b/requirements/doc.in @@ -4,7 +4,7 @@ -r base.in doc8 # reStructuredText style checker -edx_sphinx_theme # edX theme for Sphinx output +sphinx-book-theme # edX theme for Sphinx output readme_renderer # Validates README.rst for usage on PyPI sphinx # Documentation builder sphinxcontrib-napoleon # Google Style docstring support for sphinx diff --git a/requirements/doc.txt b/requirements/doc.txt index 8288545..0c14434 100644 --- a/requirements/doc.txt +++ b/requirements/doc.txt @@ -4,6 +4,8 @@ # # make upgrade # +accessible-pygments==0.0.4 + # via pydata-sphinx-theme alabaster==0.7.16 # via sphinx amqp==5.2.0 @@ -98,6 +100,7 @@ doc8==1.1.2 docutils==0.21.2 # via # doc8 + # pydata-sphinx-theme # readme-renderer # restructuredtext-lint # sphinx @@ -120,13 +123,8 @@ edx-django-utils==5.15.0 # openedx-events edx-drf-extensions==10.4.0 # via -r requirements/base.in -edx-opaque-keys[django]==2.11.0 - # via - # edx-ccx-keys - # edx-drf-extensions - # openedx-events -edx-sphinx-theme==3.1.0 - # via -r requirements/doc.in +edx-opaque-keys==2.11.0 + # via edx-drf-extensions edx-toggles==5.2.0 # via -r requirements/base.in fastavro==1.9.7 @@ -156,6 +154,7 @@ openedx-events==9.14.1 packaging==24.1 # via # drf-yasg + # pydata-sphinx-theme # sphinx pbr==6.1.0 # via stevedore @@ -167,9 +166,13 @@ psutil==6.0.0 # via edx-django-utils pycparser==2.22 # via cffi +pydata-sphinx-theme==0.14.4 + # via sphinx-book-theme pygments==2.18.0 # via + # accessible-pygments # doc8 + # pydata-sphinx-theme # readme-renderer # sphinx pyjwt[crypto]==2.9.0 @@ -202,18 +205,21 @@ semantic-version==2.10.0 # via edx-drf-extensions six==1.16.0 # via - # edx-ccx-keys - # edx-sphinx-theme # pockets # python-dateutil # sphinxcontrib-napoleon snowballstemmer==2.2.0 # via sphinx -sphinx==3.5.3 +soupsieve==2.5 + # via beautifulsoup4 +sphinx==5.3.0 # via # -r requirements/doc.in - # edx-sphinx-theme -sphinxcontrib-applehelp==2.0.0 + # pydata-sphinx-theme + # sphinx-book-theme +sphinx-book-theme==1.0.1 + # via -r requirements/doc.in +sphinxcontrib-applehelp==1.0.4 # via sphinx sphinxcontrib-devhelp==2.0.0 # via sphinx @@ -238,6 +244,11 @@ stevedore==5.3.0 text-unidecode==1.3 # via python-slugify typing-extensions==4.12.2 + # via + # asgiref + # edx-opaque-keys + # kombu + # pydata-sphinx-theme # via edx-opaque-keys tzdata==2024.1 # via celery