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

patching doc extensions to work with later sphinx versions #9556

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
18 changes: 16 additions & 2 deletions docs/_static/style.css
Expand Up @@ -15,7 +15,15 @@ Historically however, thanks to:
* {
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;
}
Expand Down Expand Up @@ -244,7 +252,10 @@ a:hover {
text-decoration: underline;
color: var(--link-hover-text);
}

a:visited {
text-decoration: none;
color: var(--link-text);
}
/* headers */

header.grid-item {
Expand All @@ -267,7 +278,10 @@ header > nav {
header > nav a {
color: var(--white);
}

header > nav > a:visited {
color: var(--white);
text-decoration: underline;
}
header > nav.mobile-only {
width: 100%;
position: absolute;
Expand Down
9 changes: 7 additions & 2 deletions docs/_templates/layout.html
Expand Up @@ -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') %}
Expand Down
2 changes: 2 additions & 0 deletions docs/conf.py
Expand Up @@ -373,6 +373,8 @@ def _i18n_warning_filter(record: logging.LogRecord) -> bool:
# 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)
Expand Down
39 changes: 32 additions & 7 deletions docs/extensions/builder.py
@@ -1,13 +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):
Expand Down Expand Up @@ -69,7 +94,7 @@ def finish(self) -> None:
'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,
}
Expand Down
2 changes: 1 addition & 1 deletion 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

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -35,7 +35,7 @@
extras_require = {
'voice': ['PyNaCl>=1.3.0,<1.6'],
'docs': [
'sphinx==4.4.0',
'sphinx==7.2.6',
CrosswaveOmega marked this conversation as resolved.
Show resolved Hide resolved
'sphinxcontrib_trio==1.1.2',
'sphinxcontrib-websupport',
'typing-extensions>=4.3,<5',
Expand Down