From 3b82ef2c02ac6fe43594b81d9c02d094fa17a5db Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 4 May 2020 18:08:19 +0200 Subject: [PATCH 1/3] Add useful resources to the index page --- CONTRIBUTING.rst => .overrides/CONTRIBUTING.rst | 0 .overrides/README.rst | 11 +++++++++++ .overrides/tools/templates/indexsidebar.html | 11 +++++++++++ conf.py | 11 ++++++++++- 4 files changed, 32 insertions(+), 1 deletion(-) rename CONTRIBUTING.rst => .overrides/CONTRIBUTING.rst (100%) create mode 100644 .overrides/README.rst create mode 100644 .overrides/tools/templates/indexsidebar.html diff --git a/CONTRIBUTING.rst b/.overrides/CONTRIBUTING.rst similarity index 100% rename from CONTRIBUTING.rst rename to .overrides/CONTRIBUTING.rst diff --git a/.overrides/README.rst b/.overrides/README.rst new file mode 100644 index 0000000000..cb924fa52d --- /dev/null +++ b/.overrides/README.rst @@ -0,0 +1,11 @@ +Overrides +========= + +This directory is recursively copied into `cpython/Doc`. +It needs to have the same structure than `cpython/Doc`. + +It allows us + +- to have our own `CONTRIBUTING.rst` guide +- change the index sidebar with links that are interesting for translators +- etc diff --git a/.overrides/tools/templates/indexsidebar.html b/.overrides/tools/templates/indexsidebar.html new file mode 100644 index 0000000000..0b57a66a20 --- /dev/null +++ b/.overrides/tools/templates/indexsidebar.html @@ -0,0 +1,11 @@ +

¡Ayúdanos a traducir!

+ + +

Recursos

+ diff --git a/conf.py b/conf.py index 9b63559aff..b53c77f4d4 100644 --- a/conf.py +++ b/conf.py @@ -33,7 +33,16 @@ os.system('mkdir -p cpython/locales/es/') os.system('ln -nfs `pwd` cpython/locales/es/LC_MESSAGES') -os.system('ln -nfs `pwd`/CONTRIBUTING.rst cpython/Doc/CONTRIBUTING.rst') + + +# Override all the files from ``.overrides`` directory +import glob +for root, dirs, files in os.walk('.overrides'): + for fname in files: + if fname == 'README.rst' and root == '.overrides': + continue + destroot = root.replace('.overrides/', '') + os.system(f'ln -nfs `pwd`/{root}/{fname} cpython/Doc/{destroot}/{fname}') gettext_compact = False locale_dirs = ['../locales', 'cpython/locales'] # relative to the sourcedir From f92cff08fc0a10c9d2d6b55069579a0a05e2b481 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 4 May 2020 18:31:59 +0200 Subject: [PATCH 2/3] Handle path properly --- conf.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/conf.py b/conf.py index b53c77f4d4..f53eac6d1a 100644 --- a/conf.py +++ b/conf.py @@ -41,8 +41,14 @@ for fname in files: if fname == 'README.rst' and root == '.overrides': continue - destroot = root.replace('.overrides/', '') - os.system(f'ln -nfs `pwd`/{root}/{fname} cpython/Doc/{destroot}/{fname}') + destroot = root.replace('.overrides', '').lstrip('/') + outputdir = os.path.join( + 'cpython', + 'Doc', + destroot, + fname, + ) + os.system(f'ln -nfs `pwd`/{root}/{fname} {outputdir}') gettext_compact = False locale_dirs = ['../locales', 'cpython/locales'] # relative to the sourcedir From 8fe90242a6e95472459c4debc78a42710c9b0a2a Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 4 May 2020 18:34:04 +0200 Subject: [PATCH 3/3] Override customsourcelink to point to our repo --- .overrides/tools/templates/customsourcelink.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .overrides/tools/templates/customsourcelink.html diff --git a/.overrides/tools/templates/customsourcelink.html b/.overrides/tools/templates/customsourcelink.html new file mode 100644 index 0000000000..25758c2065 --- /dev/null +++ b/.overrides/tools/templates/customsourcelink.html @@ -0,0 +1,13 @@ +{%- if show_source and has_source and sourcename %} +
+

{{ _('This Page') }}

+ +
+{%- endif %}