8000 DOC: Add an option to disable Google Analytics. by QuLogic · Pull Request #18557 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,15 @@ commands:
command: |
# Set epoch to date of latest tag.
export SOURCE_DATE_EPOCH="$(git log -1 --format=%at $(git describe --abbrev=0))"
make html O=-T
# Include analytics only when deploying to devdocs.
if [ "$CIRCLE_PROJECT_USERNAME" != "matplotlib" ] || \
[ "$CIRCLE_BRANCH" != "master" ] || \
[[ "$CIRCLE_PULL_REQUEST" == https://github.com/matplotlib/matplotlib/pull/* ]]; then
export ANALYTICS=False
else
export ANALYTICS=True
fi
make html O="-T -Ainclude_analytics=$ANALYTICS"
rm -r build/html/_sources
working_directory: doc
- save_cache:
Expand Down
2 changes: 2 additions & 0 deletions doc/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
{%- endif %}
</div>
</footer>
{%- if include_analytics %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
Expand All @@ -106,4 +107,5 @@
ga('send', 'pageview');

</script>
{%- endif %}
{%- endblock %}
7 changes: 6 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ def _check_dependencies():
except (subprocess.CalledProcessError, FileNotFoundError):
SHA = matplotlib.__version__

html_context = {'sha': SHA}
html_context = {
'sha': SHA,
# This will disable any analytics in the HTML templates (currently Google
# Analytics.)
'include_analytics': False,
}

project = 'Matplotlib'
copyright = ('2002 - 2012 John Hunter, Darren Dale, Eric Firing, '
Expand Down
2 changes: 1 addition & 1 deletion doc/devel/release_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ build the docs from the ``ver-doc`` branch. An easy way to arrange this is::
pip install -r requirements/doc/doc-requirements.txt
git checkout v2.0.0-doc
git clean -xfd
make -Cdoc O=-j$(nproc) html latexpdf LATEXMKOPTS="-silent -f"
make -Cdoc O="-Ainclude_analytics=True -j$(nproc)" html latexpdf LATEXMKOPTS="-silent -f"

which will build both the html and pdf version of the documentation.

Expand Down
0