Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit f3d3d33

Browse files
authored
Merge pull request #72 from saadmk11/external-version-warning
External version warning banner
2 parents cad5845 + 8dbf0f0 commit f3d3d33

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from docutils import nodes
2+
3+
try:
4+
# Avaliable from Sphinx 1.6
5+
from sphinx.util.logging import getLogger
6+
except ImportError:
7+
from logging import getLogger
8+
9+
log = getLogger(__name__)
10+
11+
12+
def process_external_version_warning_banner(app, doctree, fromdocname):
13+
"""
14+
Add warning banner for external versions in every page.
15+
16+
If the version type is external this will show a warning banner
17+
at the top of each page of the documentation.
18+
"""
19+
for document in doctree.traverse(nodes.document):
20+
text = 'This Documentation was created from pull/merge request.'
21+
prose = nodes.paragraph(text, text)
22+
warning = nodes.warning(prose, prose)
23+
document.insert(0, warning)
24+
25+
26+
def setup(app):
27+
app.connect('doctree-resolved', process_external_version_warning_banner)

0 commit comments

Comments
 (0)