FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-docs-es/conf.py at 3.14 · python/python-docs-es · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
python
/
python-docs-es
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
412
Star
365
Code
Issues
423
Pull requests
17
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
python-docs-es
/
conf.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
135 lines (107 loc) · 4.59 KB
Breadcrumbs
python-docs-es
/
conf.py
Copy path
File metadata and controls
135 lines (107 loc) · 4.59 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
# Sphinx configuration file.
#
# - import original configurations from cpython/Doc/conf.py
# - append the path considering the cpython submodule is at ./cpython
# - create the symbolic links under ./cpython/locale/es/LC_MESSAGES
# - make the build to work under Read the Docs
#
# The git submodule was created using this Stack Overflow answer
# to fetch only the commit that I needed and avoid clonning the whole history
# https://stackoverflow.com/a/27445058
#
# This can be built locally using `sphinx-build` by running
#
# $ sphinx-build -b html -d _build/doctrees -D language=es . _build/html
import
sys
import
os
import
time
from
pathlib
import
Path
sys
.
path
.
append
(
os
.
path
.
abspath
(
'cpython/Doc/tools/extensions'
))
sys
.
path
.
append
(
os
.
path
.
abspath
(
'cpython/Doc/includes'
))
# Import all the Sphinx settings from cpython.
# Warning: calling 'eval' and 'compile' is usually not recommended, but in this case
# we are relying on the official sphinx configuration from cpython.
cpython_sphinx_conf
=
Path
(
os
.
path
.
abspath
(
'cpython/Doc/conf.py'
))
eval
(
compile
(
cpython_sphinx_conf
.
read_bytes
(),
str
(
cpython_sphinx_conf
),
"exec"
),
globals
())
project
=
'Python en Español'
html_theme_path
=
[
'cpython/Doc/tools'
]
templates_path
=
[
'cpython/Doc/tools/templates'
]
html_static_path
=
[
'cpython/Doc/tools/static'
]
os
.
system
(
'mkdir -p cpython/locales/es/'
)
os
.
system
(
'ln -nfs `pwd` cpython/locales/es/LC_MESSAGES'
)
html_short_title
=
f'Documentación
{
release
}
'
html_title
=
f'Documentación de Python en Español --
{
release
}
'
# Extend settings from upstream
_exclude_patterns
=
[
# This file is not included and it's not marked as :orphan:
'distutils/_setuptools_disclaimer.rst'
,
'includes/wasm-notavail.rst'
,
]
if
'exclude_patterns'
in
globals
():
exclude_patterns
+=
_exclude_patterns
else
:
exclude_patterns
=
_exclude_patterns
_extensions
=
[
'sphinx_autorun'
,
'sphinx_tabs.tabs'
,
'sphinxemoji.sphinxemoji'
,
]
if
'extensions'
in
globals
():
extensions
+=
_extensions
else
:
extensions
=
_extensions
if
os
.
environ
.
get
(
'SPHINX_GETTEXT'
)
is
None
:
# Override all the files from ``.overrides`` directory
overrides_paths
=
Path
(
'.overrides'
)
for
path
in
overrides_paths
.
glob
(
'**/*.*'
):
if
path
.
name
==
'README.rst'
and
path
.
parent
==
'.overrides'
:
continue
# Skip the files in the .overrides/logo directory
# to avoid ln issues.
if
str
(
path
.
parent
).
endswith
(
"logo"
):
continue
destroot
=
str
(
path
.
parent
).
replace
(
'.overrides'
,
''
).
lstrip
(
'/'
)
outputdir
=
Path
(
'cpython/Doc'
)
/
destroot
/
path
.
name
os
.
system
(
f'ln -nfs `pwd`/
{
path
.
parent
}
/
{
path
.
name
}
{
outputdir
}
'
)
gettext_compact
=
False
locale_dirs
=
[
'../locales'
,
'cpython/locales'
]
# relative to the sourcedir
# NOTE: Read the Docs does not support "multi document output".
# So, we put all the documentation as a single file for now.
_stdauthor
=
r'Guido van Rossum\\and the Python development team'
latex_documents
=
[
(
'contents'
,
'python-docs-es.tex'
,
u'Documentación de Python en Español'
,
_stdauthor
,
'manual'
),
]
# autorun is used, among other things, to run potodo, which generates non-ascii output
# starting with 0.30. autorun OTOH defaults to use ascii to decode console/python output.
# Let's switch to utf-8 instead.
autorun_languages
=
{
"console_output_encoding"
:
"utf-8"
,
"pycon_output_encoding"
:
"utf-8"
,
}
def
setup
(
app
):
def
add_contributing_banner
(
app
,
doctree
):
"""
Insert a banner at the top of the index.
This way, we can easily communicate people to help with the translation,
pointing them to different resources.
"""
if
app
.
builder
.
format
!=
'html'
:
# Do not include the banner when building with other formats
# (this is useful when using -b gettext)
return
from
docutils
import
nodes
,
core
from
textwrap
import
dedent
message
=
dedent
(
f"""
\
¡Ayúdanos a traducir la documentación oficial de Python al Español!
Puedes encontrar más información en `Como contribuir </es/
{
version
}
/CONTRIBUTING.html>`_.
Ayuda a acercar Python a más personas de habla hispana.
"""
)
paragraph
=
core
.
publish_doctree
(
message
)[
0
]
banner
=
nodes
.
note
(
ids
=
[
'contributing-banner'
])
banner
.
append
(
paragraph
)
for
document
in
doctree
.
traverse
(
nodes
.
document
):
document
.
insert
(
0
,
banner
)
# Change the sourcedir programmatically because Read the Docs always call it with `.`
app
.
srcdir
=
Path
(
os
.
getcwd
()
+
'/cpython/Doc'
)
app
.
connect
(
'doctree-read'
,
add_contributing_banner
)
Back
|
FazBrowse Home
|
New Git URL