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

API Docs & Annotations #2006

Merged
merged 22 commits into from
Feb 28, 2021
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
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ endif
black:
black --config ./.black.toml sanic tests

fix-import: black
isort sanic tests --profile=black
isort:
isort sanic tests --profile=black

pretty: black isort

docs-clean:
cd docs && make clean
Expand All @@ -83,6 +84,10 @@ docs: docs-clean
docs-test: docs-clean
cd docs && make dummy

docs-serve:
# python -m http.server --directory=./docs/_build/html 9999
sphinx-autobuild docs docs/_build/html --port 9999 --watch ./sanic

changelog:
python scripts/changelog.py

Expand Down
4 changes: 4 additions & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.wy-side-nav-search,
.wy-nav-top {
background: #444444;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 53 additions & 28 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,36 @@

# Add support for auto-doc
import recommonmark

from recommonmark.transform import AutoStructify


# Ensure that sanic is present in the path, to allow sphinx-apidoc to
# autogenerate documentation from docstrings
root_directory = os.path.dirname(os.getcwd())
sys.path.insert(0, root_directory)

import sanic


# -- General configuration ------------------------------------------------

extensions = ['sphinx.ext.autodoc', "recommonmark"]
extensions = ["sphinx.ext.autodoc", "recommonmark"]

templates_path = ['_templates']
templates_path = ["_templates"]

# Enable support for both Restructured Text and Markdown
source_suffix = ['.rst', '.md']
source_suffix = [".rst", ".md"]

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'Sanic'
copyright = '2018, Sanic contributors'
author = 'Sanic contributors'
project = "Sanic"
copyright = "2021, Sanic Community Organization"
author = "Sanic Community Organization"

html_logo = "./_static/sanic-framework-logo-white-400x97.png"
# 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.
Expand All @@ -52,18 +56,18 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'
language = "en"

# 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
#
# modules.rst is generated by sphinx-apidoc but is unused. This suppresses
# a warning about it.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'modules.rst']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "modules.rst"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -72,33 +76,30 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# 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']

html_static_path = ["_static"]
html_css_files = ["custom.css"]
# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'Sanicdoc'
htmlhelp_basename = "Sanicdoc"

# -- 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',
Expand All @@ -107,23 +108,37 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [(master_doc, 'Sanic.tex', 'Sanic Documentation',
'Sanic contributors', 'manual'), ]
latex_documents = [
(
master_doc,
"Sanic.tex",
"Sanic Documentation",
"Sanic contributors",
"manual",
),
]

# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, 'sanic', 'Sanic Documentation', [author], 1)]
man_pages = [(master_doc, "sanic", "Sanic Documentation", [author], 1)]

# -- 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 = [
(master_doc, 'Sanic', 'Sanic Documentation', author, 'Sanic',
'One line description of project.', 'Miscellaneous'),
(
master_doc,
"Sanic",
"Sanic Documentation",
author,
"Sanic",
"One line description of project.",
"Miscellaneous",
),
]

# -- Options for Epub output ----------------------------------------------
Expand All @@ -135,17 +150,27 @@
epub_copyright = copyright

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
epub_exclude_files = ["search.html"]

# -- Custom Settings -------------------------------------------------------

suppress_warnings = ['image.nonlocal_uri']
suppress_warnings = ["image.nonlocal_uri"]


autodoc_typehints = "description"
autodoc_default_options = {
"member-order": "groupwise",
}


# app setup hook
def setup(app):
app.add_config_value('recommonmark_config', {
'enable_eval_rst': True,
'enable_auto_doc_ref': False,
}, True)
app.add_config_value(
"recommonmark_config",
{
"enable_eval_rst": True,
"enable_auto_doc_ref": False,
},
True,
)
app.add_transform(AutoStructify)
30 changes: 1 addition & 29 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,9 @@ Guides
======

.. toctree::
:maxdepth: 2
:maxdepth: 4

sanic/getting_started
sanic/config
sanic/logging
sanic/request_data
sanic/response
sanic/cookies
sanic/routing
sanic/blueprints
sanic/static_files
sanic/versioning
sanic/exceptions
sanic/middleware
sanic/websocket
sanic/decorators
sanic/streaming
sanic/class_based_views
sanic/custom_protocol
sanic/sockets
sanic/ssl
sanic/debug_mode
sanic/testing
sanic/deploying
sanic/nginx
sanic/extensions
sanic/examples
sanic/changelog
sanic/contributing
sanic/api_reference
sanic/asyncio_python37


Module Documentation
Expand Down
Loading