-
Notifications
You must be signed in to change notification settings - Fork 396
Omitir directorio .overrides/logo para ln y mejoras #1840
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,21 +13,28 @@ | |
# | ||
# $ sphinx-build -b html -d _build/doctrees -D language=es . _build/html | ||
|
||
import sys, os, time | ||
import sys | ||
import os | ||
import time | ||
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 | ||
# This import will trigger warnings on the 'Include/patchlevel.h' | ||
# not being found, because it execute the content of the whole file, | ||
# and there there is a local call to 'get_header_version' like the one | ||
# we have in a few lines. | ||
sys.path.insert(0, os.path.abspath('cpython/Doc')) | ||
from conf import * | ||
|
||
# Call patchlevel with the proper path to get the version from | ||
# instead of hardcoding it | ||
import patchlevel | ||
version, release = patchlevel.get_header_version_info(os.path.abspath('cpython/Doc')) | ||
from patchlevel import get_header_version_info | ||
version, release = get_header_version_info(os.path.abspath('cpython/Doc')) | ||
|
||
project = 'Python en Español' | ||
copyright = '2001-%s, Python Software Foundation' % time.strftime('%Y') | ||
year = time.strftime("%Y") | ||
copyright = f'2001-{year}, Python Software Foundation' | ||
|
||
html_theme_path = ['cpython/Doc/tools'] | ||
templates_path = ['cpython/Doc/tools/templates'] | ||
|
@@ -61,14 +68,18 @@ | |
extensions = _extensions | ||
|
||
|
||
if not os.environ.get('SPHINX_GETTEXT') == 'True': | ||
if os.environ.get('SPHINX_GETTEXT') is None: | ||
# Override all the files from ``.overrides`` directory | ||
from pathlib import Path | ||
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"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Creen que valga la pena colocar este if y el anterior como filtros, y sacar la acción del There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. como estaban motivadas por cosas distintas, preferí dejarlo separado, mal que mal, lo del logo es bastante nuevo. No sé si ganemos muchos con el tema de la función, total el archivo |
||
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}') | ||
|
@@ -85,6 +96,7 @@ | |
_stdauthor, 'manual'), | ||
] | ||
|
||
|
||
def setup(app): | ||
|
||
def add_contributing_banner(app, doctree): | ||
|
@@ -101,10 +113,13 @@ def add_contributing_banner(app, doctree): | |
return | ||
|
||
from docutils import nodes, core | ||
from textwrap import dedent | ||
|
||
message = '¡Ayúdanos a traducir la documentación oficial de Python al Español! ' \ | ||
f'Puedes encontrar más información en `Como contribuir </es/{version}/CONTRIBUTING.html>`_. ' \ | ||
'Ayuda a acercar Python a más personas de habla hispana.' | ||
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']) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me imagino que está explícito, por si tiene un valor, cual sea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Era para hacerlo explícito la verdad, a pesar que tenemos cosas tan raras como:
era para dejar en claro que quería mirar si
get
retornabaNone
, explicando así que la variable no está definida.El problema con usar
not os.environ.get(...)
es que si la variable está definida a nada, entrará, y la idea es que si alguien ya la definió por alguna razón, que no entre. Por ejemplo:pero para términos de este script, dudo que en algún momento alguien defina la variable a algo más :P pero es la costumbre de estar preparado para todo jaja
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Está bien chistoso porque justo el
0
arroja un False jajaja.Igual pues, con que te regrese un '' o no esté (None) daría True, pero sí, igual y un poco exagerado, el
is None
está bastante explícito, bueno saberlo la verdad.