Skip to content

Commit bf3827a

Browse files
authored
Merge pull request #18557 from QuLogic/no-ga
DOC: Add an option to enable Google Analytics.
2 parents 21b9af2 + 2dacc6c commit bf3827a

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

.circleci/config.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ commands:
8787
command: |
8888
# Set epoch to date of latest tag.
8989
export SOURCE_DATE_EPOCH="$(git log -1 --format=%at $(git describe --abbrev=0))"
90-
make html O=-T
90+
# Include analytics only when deploying to devdocs.
91+
if [ "$CIRCLE_PROJECT_USERNAME" != "matplotlib" ] || \
92+
[ "$CIRCLE_BRANCH" != "master" ] || \
93+
[[ "$CIRCLE_PULL_REQUEST" == https://github.com/matplotlib/matplotlib/pull/* ]]; then
94+
export ANALYTICS=False
95+
else
96+
export ANALYTICS=True
97+
fi
98+
make html O="-T -Ainclude_analytics=$ANALYTICS"
9199
rm -r build/html/_sources
92100
working_directory: doc
93101
- save_cache:

doc/_templates/layout.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
{%- endif %}
9797
</div>
9898
</footer>
99+
{%- if include_analytics %}
99100
<script>
100101
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
101102
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@@ -106,4 +107,5 @@
106107
ga('send', 'pageview');
107108

108109
</script>
110+
{%- endif %}
109111
{%- endblock %}

doc/conf.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,12 @@ def _check_dependencies():
183183
except (subprocess.CalledProcessError, FileNotFoundError):
184184
SHA = matplotlib.__version__
185185

186-
html_context = {'sha': SHA}
186+
html_context = {
187+
'sha': SHA,
188+
# This will disable any analytics in the HTML templates (currently Google
189+
# Analytics.)
190+
'include_analytics': False,
191+
}
187192

188193
project = 'Matplotlib'
189194
copyright = ('2002 - 2012 John Hunter, Darren Dale, Eric Firing, '

doc/devel/release_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ build the docs from the ``ver-doc`` branch. An easy way to arrange this is::
313313
pip install -r requirements/doc/doc-requirements.txt
314314
git checkout v2.0.0-doc
315315
git clean -xfd
316-
make -Cdoc O=-j$(nproc) html latexpdf LATEXMKOPTS="-silent -f"
316+
make -Cdoc O="-Ainclude_analytics=True -j$(nproc)" html latexpdf LATEXMKOPTS="-silent -f"
317317

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

0 commit comments

Comments
 (0)