1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
Description: Patch doc extensions to work with later sphinx versions
Author: CrosswaveOmega <xtream2pro@gmail.com>
Origin: https://github.com/Rapptz/discord.py/pull/9556
Bug: https://github.com/Rapptz/discord.py/issues/9938
Bug-Debian: https://bugs.debian.org/1057608
Reviewed-by: Ben Westover <me@benthetechguy.net>
Last-Update: 2025-01-02
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/docs/_static/style.css
+++ b/docs/_static/style.css
@@ -15,7 +15,15 @@
* {
box-sizing: border-box;
}
+/*Overriding undesired elements.*/
+nav.contents,
+aside.topic {
+ border: none;
+ padding: inherit!important;
+ margin: inherit!important;
+}
+/* root*/
section {
word-break: break-word;
}
@@ -250,7 +258,10 @@
text-decoration: underline;
color: var(--link-hover-text);
}
-
+a:visited {
+ text-decoration: none;
+ color: var(--link-text);
+}
/* headers */
header.grid-item {
@@ -273,7 +284,10 @@
header > nav a {
color: var(--white);
}
-
+header > nav > a:visited {
+ color: var(--white);
+ text-decoration: underline;
+}
header > nav.mobile-only {
width: 100%;
position: absolute;
--- a/docs/_templates/layout.html
+++ b/docs/_templates/layout.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html>
+<html data-content_root="{{ content_root }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -32,14 +32,19 @@
{{ "}" }}
</script>
{%- for js in script_files %}
+
+ {%- if js!="_static/documentation_options.js" %}
{{ js_tag(js) }}
+ {%- else %}
+ <!-- Already imported documentation_options-->
+ {%-endif %}
{%- endfor %}
{%- endblock %}
{%- if pageurl %}
<link rel="canonical" href="{{ pageurl|e }}" />
{%- endif %}
- {%- if favicon %}
- <link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1)|e }}"/>
+ {%- if favicon_url %}
+ <link rel="shortcut icon" href="{{ pathto(favicon_url, 1)|e }}"/>
{%- endif %}
{%- block linktags %}
{%- if hasdoc('about') %}
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -374,6 +374,8 @@
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
+#Create table of contents entries for domain objects (e.g. functions, classes, attributes, etc.). Default is True.
+toc_object_entries=False
def setup(app):
if app.config.language == 'ja':
app.config.intersphinx_mapping['py'] = ('https://docs.python.org/ja/3', None)
--- a/docs/extensions/builder.py
+++ b/docs/extensions/builder.py
@@ -1,14 +1,38 @@
+import datetime
+import os
+import re
+
+from sphinx.builders.gettext import GettextRenderer, I18nBuilder, MessageCatalogBuilder, should_write
from sphinx.builders.html import StandaloneHTMLBuilder
-from sphinx.builders.gettext import MessageCatalogBuilder, I18nBuilder, timestamp, ltz, should_write, GettextRenderer
+from sphinx.environment.adapters.indexentries import IndexEntries
from sphinx.locale import __
-from sphinx.util import status_iterator
from sphinx.util.osutil import ensuredir
-from sphinx.environment.adapters.indexentries import IndexEntries
from sphinx.writers.html5 import HTML5Translator
-import datetime
-import os
-import re
+try:
+ # Latest sphinx version lets you import ctime directly.
+ from sphinx import version_info
+
+ comp = version_info[:3]
+ if comp >= (7, 2, 0):
+ from sphinx.builders.gettext import ctime
+ from sphinx.util.display import status_iterator
+ else:
+ from sphinx.builders.gettext import ltz, timestamp
+
+ ctime = datetime.datetime.fromtimestamp(timestamp, ltz).strftime('%Y-%m-%d %H:%M%z')
+ from sphinx.util import status_iterator
+
+except Exception as exc:
+ # Fallback
+ import time
+
+ if (source_date_epoch := os.getenv('SOURCE_DATE_EPOCH')) is not None:
+ timestamp = time.gmtime(float(source_date_epoch))
+ else:
+ # determine timestamp once to remain unaffected by DST changes during build
+ timestamp = time.localtime()
+ ctime = time.strftime('%Y-%m-%d %H:%M%z', timestamp)
class DPYHTML5Translator(HTML5Translator):
def visit_section(self, node):
@@ -69,7 +93,7 @@
'project': self.config.project,
'last_translator': self.config.gettext_last_translator,
'language_team': self.config.gettext_language_team,
- 'ctime': datetime.datetime.fromtimestamp(timestamp, ltz).strftime('%Y-%m-%d %H:%M%z'),
+ 'ctime': ctime,
'display_location': self.config.gettext_location,
'display_uuid': self.config.gettext_uuid,
}
--- a/docs/extensions/details.py
+++ b/docs/extensions/details.py
@@ -1,5 +1,5 @@
from docutils.parsers.rst import Directive
-from docutils.parsers.rst import states, directives
+from docutils.parsers.rst import directives
from docutils.parsers.rst.roles import set_classes
from docutils import nodes
|