Use html_extra_template_renderer to replace the current robots.txt rendering script

This commit is contained in:
Kamil Śliwak 2021-07-15 13:12:59 +02:00
parent 2bebc2f822
commit 8c5ae508f9
3 changed files with 5 additions and 29 deletions

View File

@ -161,7 +161,7 @@ html_js_files = ["js/toggle.js"]
# Add any extra paths that contain custom files (such as robots.txt or # Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied # .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation. # directly to the root of the documentation.
html_extra_path = ["_static/css", "_static/robots.txt"] html_extra_path = ["_static/css"]
# List of templates of static files to be included in the HTML output. # List of templates of static files to be included in the HTML output.
# Keys represent paths to input files and values are dicts containing: # Keys represent paths to input files and values are dicts containing:
@ -170,6 +170,10 @@ html_extra_path = ["_static/css", "_static/robots.txt"]
# All paths must be absolute. # All paths must be absolute.
# Rendered templates are automatically added to html_extra_path setting. # Rendered templates are automatically added to html_extra_path setting.
html_extra_templates = { html_extra_templates = {
os.path.join(ROOT_PATH, "robots.txt.template"): {
'target': os.path.join(ROOT_PATH, "_static/robots.txt"),
'context': {'LATEST_VERSION': version},
}
} }
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,

View File

@ -27,7 +27,6 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
set -e set -e
scripts/update_robotstxt.sh
cd docs cd docs
pip3 install -r requirements.txt pip3 install -r requirements.txt
sphinx-build -nW -b html -d _build/doctrees . _build/html sphinx-build -nW -b html -d _build/doctrees . _build/html

View File

@ -1,27 +0,0 @@
#!/usr/bin/env bash
#------------------------------------------------------------------------------
# solidity is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# solidity is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with solidity. If not, see <http://www.gnu.org/licenses/>
#
# (c) 2021 solidity contributors.
#------------------------------------------------------------------------------
set -eu
repo_root="$(dirname "$0")/.."
robots_template_path="${repo_root}/docs/robots.txt.template"
robots_txt_path="${repo_root}/docs/_static/robots.txt"
latest_version=$("${repo_root}/scripts/get_version.sh")
sed -E -e "s/\{\{[[:space:]]LATEST_VERSION[[:space:]]\}\}/${latest_version}/g" "$robots_template_path" > "$robots_txt_path"