diff --git a/docs/conf.py b/docs/conf.py index 3eb7e3178b..053fb7d942 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,16 +1,3 @@ -# -# pycord documentation build configuration file, created by -# sphinx-quickstart on Fri Aug 21 05:43:30 2015. -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - import os import sys from importlib.metadata import version as get_version @@ -49,22 +36,12 @@ def write_new(): write_new() c_file.close() -# 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. sys.path.insert(0, os.path.abspath("..")) sys.path.append(os.path.abspath("extensions")) # -- General configuration ------------------------------------------------ -# If your documentation needs a minimal Sphinx version, state it here. -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. extensions = [ - # "builder", "sphinx.ext.autodoc", "sphinx.ext.autosectionlabel", "sphinx.ext.autosummary", @@ -74,7 +51,6 @@ def write_new(): "sphinx.ext.viewcode", "sphinx.ext.duration", "sphinxcontrib_trio", - # "details", "exception_hierarchy", "attributetable", "resourcelinks", @@ -94,9 +70,10 @@ def write_new(): autodoc_member_order = "bysource" autodoc_typehints = "signature" -# Disable overload signature injection to keep docs concise + +# Disable overload signature injection to keep docs concise. See https://github.com/Pycord-Development/pycord/pull/3124 typehints_document_overloads = False -# maybe consider this? +# maybe consider this? # TODO(Paillat-dev): Consider this # napoleon_attr_annotations = False extlinks = { @@ -104,7 +81,6 @@ def write_new(): "dpy-issue": ("https://github.com/Rapptz/discord.py/issues/%s", "GH-%s"), } -# Links used for cross-referencing stuff in other documentation intersphinx_mapping = { "py": ("https://docs.python.org/3", None), "aio": ("https://docs.aiohttp.org/en/stable/", None), @@ -121,30 +97,18 @@ def write_new(): .. _gateway_link: https://docs.discord.com/developers/events/gateway-events """ -# Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] -# The suffix of source filenames. source_suffix = { ".rst": "restructuredtext", # Used For The Other Docs ".md": "markdown", # Used ONLY In the Guide For Faster Making Time } -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The master toctree document. master_doc = "index" -# General information about the project. project = "Pycord" copyright = "2015-2021, Rapptz & 2021-present, Pycord Development" -# 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 full version, including alpha/beta/rc tags. release = get_version("py-cord") @@ -160,52 +124,17 @@ def write_new(): html_title = f"{project} v{version} Documentation" -# 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 = "en" gettext_compact = False gettext_uuid = True -locale_dirs = ["locales/"] # Added locale directory - -# 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' +locale_dirs = ["locales/"] -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. exclude_patterns = ["_build", "node_modules", "build", "locales"] -# 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 = "friendly" -# 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 - - # Nitpicky mode options nitpick_ignore_files = [ "migrating_to_v1", @@ -215,10 +144,6 @@ def write_new(): # -- Options for HTML output ---------------------------------------------- -html_experimental_html5_writer = True - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. html_theme = "furo" html_context = { @@ -239,9 +164,6 @@ def write_new(): "guide": "https://guide.pycord.dev/", } -# 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. base_colors = { "white": "#ffffff", "grey-1": "#f9f9fa", @@ -260,7 +182,7 @@ def write_new(): "blue-4": "#003eaa", "blue-5": "#002275", "blue-6": "#000f40", - "blurple": "#7289da", + "blurple": "#5865F2", } html_theme_options = { @@ -303,46 +225,13 @@ def write_new(): }, } -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# 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 = "./images/pycord_logo.png" - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. html_favicon = "./images/pycord.ico" -# 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_css_files = ["css/custom.css"] html_js_files = ["js/custom.js"] -# 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 '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' - -# 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 = { "**": [ "sidebar/brand.html", @@ -356,111 +245,22 @@ def write_new(): ] } -# 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', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' html_search_language = "en" -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -# 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 = "_static/js/scorer.js" - -# html_js_files = ["custom.js", "settings.js", "copy.js", "sidebar.js"] - -# Output file base name for HTML help builder. htmlhelp_basename = "pycorddoc" # -- 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_documents = [ ("index", "Pycord.tex", "Pycord Documentation", "Pycord Development", "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 = [] - -# 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 = [("index", "Pycord", "Pycord Documentation", ["Pycord Development"], 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 = [ ( "index", @@ -468,24 +268,11 @@ def write_new(): "Pycord Documentation", "Pycord Development", "Pycord", - "One line description of project.", + "An async Discord API wrapper for Python.", "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 - - linkcheck_ignore = [ r"https://docs.discord.com/developers/.*#", r"https://support(?:-dev)?.discord.com/hc/en-us/articles/.*", diff --git a/docs/extensions/builder.py b/docs/extensions/builder.py deleted file mode 100644 index 6656025b8a..0000000000 --- a/docs/extensions/builder.py +++ /dev/null @@ -1,84 +0,0 @@ -from sphinx.builders.html import StandaloneHTMLBuilder -from sphinx.environment.adapters.indexentries import IndexEntries -from sphinx.writers.html5 import HTML5Translator - - -class DPYHTML5Translator(HTML5Translator): - def visit_section(self, node) -> None: - self.section_level += 1 - self.body.append(self.starttag(node, "section")) - - def depart_section(self, node) -> None: - self.section_level -= 1 - self.body.append("\n") - - def visit_table(self, node) -> None: - self.body.append('
') - super().visit_table(node) - - def depart_table(self, node) -> None: - super().depart_table(node) - self.body.append("
") - - -class DPYStandaloneHTMLBuilder(StandaloneHTMLBuilder): - # This is mostly copy pasted from Sphinx. - def write_genindex(self) -> None: - # the total count of lines for each index letter, used to distribute - # the entries into two columns - genindex = IndexEntries(self.env).create_index(self, group_entries=False) - indexcounts = [] - for _k, entries in genindex: - indexcounts.append( - sum(1 + len(subitems) for _, (_, subitems, _) in entries) - ) - - genindexcontext = { - "genindexentries": genindex, - "genindexcounts": indexcounts, - "split_index": self.config.html_split_index, - } - - if self.config.html_split_index: - self.handle_page("genindex", genindexcontext, "genindex-split.html") - self.handle_page("genindex-all", genindexcontext, "genindex.html") - for (key, entries), count in zip(genindex, indexcounts): - ctx = { - "key": key, - "entries": entries, - "count": count, - "genindexentries": genindex, - } - self.handle_page(f"genindex-{key}", ctx, "genindex-single.html") - else: - self.handle_page("genindex", genindexcontext, "genindex.html") - - -def add_custom_jinja2(app) -> None: - env = app.builder.templates.environment - env.tests["prefixedwith"] = str.startswith - env.tests["suffixedwith"] = str.endswith - - -def add_builders(app) -> None: - """This is necessary because RTD injects their own for some reason.""" - app.set_translator("html", DPYHTML5Translator, override=True) - app.add_builder(DPYStandaloneHTMLBuilder, override=True) - - try: - original = app.registry.builders["readthedocs"] - except KeyError: - pass - else: - injected_mro = tuple( - base if base is not StandaloneHTMLBuilder else DPYStandaloneHTMLBuilder - for base in original.mro()[1:] - ) - new_builder = type(original.__name__, injected_mro, {"name": "readthedocs"}) - app.set_translator("readthedocs", DPYHTML5Translator, override=True) - app.add_builder(new_builder, override=True) - - -def setup(app) -> None: - add_builders(app) - app.connect("builder-inited", add_custom_jinja2) diff --git a/docs/extensions/details.py b/docs/extensions/details.py deleted file mode 100644 index 97e89b4f65..0000000000 --- a/docs/extensions/details.py +++ /dev/null @@ -1,68 +0,0 @@ -from docutils import nodes -from docutils.parsers.rst import Directive, directives, states -from docutils.parsers.rst.roles import set_classes - - -class details(nodes.General, nodes.Element): - pass - - -class summary(nodes.General, nodes.Element): - pass - - -def visit_details_node(self, node): - self.body.append( - self.starttag(node, "details", CLASS=node.attributes.get("class", "")) - ) - - -def visit_summary_node(self, node): - self.body.append( - self.starttag(node, "summary", CLASS=node.attributes.get("summary-class", "")) - ) - self.body.append(node.rawsource) - - -def depart_details_node(self, node): - self.body.append("\n") - - -def depart_summary_node(self, node): - self.body.append("") - - -class DetailsDirective(Directive): - final_argument_whitespace = True - optional_arguments = 1 - - option_spec = { - "class": directives.class_option, - "summary-class": directives.class_option, - } - - has_content = True - - def run(self): - set_classes(self.options) - self.assert_has_content() - - text = "\n".join(self.content) - node = details(text, **self.options) - - if self.arguments: - summary_node = summary(self.arguments[0], **self.options) - ( - summary_node.source, - summary_node.line, - ) = self.state_machine.get_source_and_line(self.lineno) - node += summary_node - - self.state.nested_parse(self.content, self.content_offset, node) - return [node] - - -def setup(app): - app.add_node(details, html=(visit_details_node, depart_details_node)) - app.add_node(summary, html=(visit_summary_node, depart_summary_node)) - app.add_directive("details", DetailsDirective) diff --git a/docs/index.rst b/docs/index.rst index c4d4b9fc51..6635263b16 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,7 +1,7 @@ .. pycord documentation master file, created by - sphinx-quickstart on Fri Aug 21 05:43:30 2015. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. +sphinx-quickstart on Fri Aug 21 05:43:30 2015. +You can adapt this file completely to your liking, but it should at least +contain the root `toctree` directive. Welcome to Pycord ================= @@ -25,7 +25,7 @@ Getting started Is this your first time using the library? This is the place to get started! -- **First steps:** :doc:`installing` | :doc:`quickstart` | :doc:`logging` | :resource:`Guide ` +- **First steps:** :doc:`installing` | :doc:`quickstart` | :doc:`logging` | :doc:`faq` | :resource:`Guide ` - **Working with Discord:** :doc:`discord` | :doc:`intents` - **Examples:** Many examples are available in the :resource:`repository `.