From e58c07dd16dde37911db02625c39322156ff55cd Mon Sep 17 00:00:00 2001 From: TunaLobster Date: Thu, 3 Mar 2022 14:41:37 -0600 Subject: [PATCH] Add configuration warning for sphinxcontrib-youtube Also adds a work around to keep older build environments functional by using sphinxcontrib.vimeo --- Sphinxsetup.bat | 5 +---- Sphinxsetup.sh | 3 --- antennatracker/source/conf.py | 13 +----------- ardupilot/source/conf.py | 13 +----------- blimp/source/conf.py | 13 +----------- common_conf.py | 37 ++++++++++++++++++++++++++++++++++- copter/source/conf.py | 13 +----------- dev/source/conf.py | 13 +----------- mavproxy/source/conf.py | 13 +----------- plane/source/conf.py | 13 +----------- planner/source/conf.py | 13 +----------- planner2/source/conf.py | 13 +----------- rover/source/conf.py | 13 +----------- 13 files changed, 47 insertions(+), 128 deletions(-) diff --git a/Sphinxsetup.bat b/Sphinxsetup.bat index 41ab738c7d..2594563b4f 100644 --- a/Sphinxsetup.bat +++ b/Sphinxsetup.bat @@ -1,5 +1,5 @@ rem remove any existing packages that may cause conflicts -pip uninstall -y sphinx lxml sphinx-rtd-theme sphinxcontrib-youtube sphinxcontrib.vimeo beautifulsoup4 +pip uninstall -y sphinx lxml sphinx-rtd-theme sphinxcontrib-youtube beautifulsoup4 rem Install sphinx pip install --upgrade sphinx @@ -13,9 +13,6 @@ pip install --upgrade git+https://github.com/ArduPilot/sphinx_rtd_theme.git rem and a youtube plugin: pip install --upgrade git+https://github.com/sphinx-contrib/youtube.git -rem and a vimeo plugin: -pip install --upgrade git+https://github.com/ArduPilot/sphinxcontrib.vimeo.git - rem and a parser to use getting posts from Discourse (forum) and insert in FrontEnd pip install --upgrade beautifulsoup4 diff --git a/Sphinxsetup.sh b/Sphinxsetup.sh index 8612a7cfba..0c29c752c8 100755 --- a/Sphinxsetup.sh +++ b/Sphinxsetup.sh @@ -60,9 +60,6 @@ python3 -m pip install --user --upgrade git+https://github.com/ArduPilot/sphinx_ # and a youtube plugin: python3 -m pip install --user --upgrade git+https://github.com/sphinx-contrib/youtube.git -# and a vimeo plugin: -python3 -m pip install --user --upgrade git+https://github.com/ArduPilot/sphinxcontrib.vimeo.git - # and a parser to use getting posts from Discourse (forum) and insert in FrontEnd python3 -m pip install --user --upgrade beautifulsoup4 diff --git a/antennatracker/source/conf.py b/antennatracker/source/conf.py index a4a047fa9d..b2381ce384 100644 --- a/antennatracker/source/conf.py +++ b/antennatracker/source/conf.py @@ -33,18 +33,7 @@ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.imgmath', - 'sphinx.ext.ifconfig', - 'sphinxcontrib.youtube', #For youtube embedding - 'sphinxcontrib.vimeo', #For vimeo embedding -] +extensions = common_conf.extensions # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/ardupilot/source/conf.py b/ardupilot/source/conf.py index 9784af0c17..4345b44021 100644 --- a/ardupilot/source/conf.py +++ b/ardupilot/source/conf.py @@ -31,18 +31,7 @@ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.imgmath', - 'sphinx.ext.ifconfig', - 'sphinxcontrib.youtube', #For youtube embedding - 'sphinxcontrib.vimeo', #For vimeo embedding -] +extensions = common_conf.extensions # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/blimp/source/conf.py b/blimp/source/conf.py index a98372b724..5e59403a1b 100644 --- a/blimp/source/conf.py +++ b/blimp/source/conf.py @@ -33,18 +33,7 @@ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.imgmath', - 'sphinx.ext.ifconfig', - 'sphinxcontrib.youtube', #For youtube embedding - 'sphinxcontrib.vimeo', #For vimeo embedding -] +extensions = common_conf.extensions # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/common_conf.py b/common_conf.py index db43b408f8..15b2450e3c 100644 --- a/common_conf.py +++ b/common_conf.py @@ -2,7 +2,42 @@ # # This contains common configuration information for the ardupilot wikis. # This information is imported by the conf.py files in each of the sub wikis -# + +import warnings +from packaging import version +import pkg_resources + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.intersphinx', + 'sphinx.ext.todo', + 'sphinx.ext.imgmath', + 'sphinx.ext.ifconfig', + 'sphinxcontrib.youtube', # For youtube embedding +] + + +def custom_formatwarning(msg, *args, **kwargs): + # ignore everything except the message + return str(msg) + '\n' + + +warnings.formatwarning = custom_formatwarning + +# Check if sphinxcontrib.youtube version is high enough to handle vimeo and older python versions +if version.parse(pkg_resources.get_distribution('sphinxcontrib-youtube').version) < version.parse('1.0.1'): + warnings.warn('\033[93mModule sphinxcontrib-youtube is outdated. PDF documentation cannot be built. ' + + 'Please run "python3 -m pip install --upgrade sphinxcontrib-youtube"') + try: + # Check if sphinxcontrib.vimeo extension is present, fallback to using that to handle vimeo + import sphinxcontrib.vimeo # noqa: F401 + extensions.append('sphinxcontrib.vimeo') # For vimeo embedding + except ImportError: # change to ModuleNotFoundError when only python >=3.6 is supported + warnings.warn('\033[93mModule sphinxcontrib-youtube is old and sphinxcontrib-vimeo is not installed.' + + 'Please run the wiki build setup script.') # Set False to re-enable warnings for non-local images. disable_non_local_image_warnings = True diff --git a/copter/source/conf.py b/copter/source/conf.py index 8427d505f9..ea6a6e06a6 100644 --- a/copter/source/conf.py +++ b/copter/source/conf.py @@ -33,18 +33,7 @@ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.imgmath', - 'sphinx.ext.ifconfig', - 'sphinxcontrib.youtube', #For youtube embedding - 'sphinxcontrib.vimeo', #For vimeo embedding -] +extensions = common_conf.extensions # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/dev/source/conf.py b/dev/source/conf.py index 631560c35e..89d9ebe339 100644 --- a/dev/source/conf.py +++ b/dev/source/conf.py @@ -31,18 +31,7 @@ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.imgmath', - 'sphinx.ext.ifconfig', - 'sphinxcontrib.youtube', #For youtube embedding - 'sphinxcontrib.vimeo', #For vimeo embedding -] +extensions = common_conf.extensions # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/mavproxy/source/conf.py b/mavproxy/source/conf.py index 8df801f63c..2871b0664a 100644 --- a/mavproxy/source/conf.py +++ b/mavproxy/source/conf.py @@ -31,18 +31,7 @@ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.imgmath', - 'sphinx.ext.ifconfig', - 'sphinxcontrib.youtube', #For youtube embedding - 'sphinxcontrib.vimeo', #For vimeo embedding -] +extensions = common_conf.extensions # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/plane/source/conf.py b/plane/source/conf.py index 7347de88de..9655ce8353 100644 --- a/plane/source/conf.py +++ b/plane/source/conf.py @@ -33,18 +33,7 @@ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.imgmath', - 'sphinx.ext.ifconfig', - 'sphinxcontrib.youtube', #For youtube embedding - 'sphinxcontrib.vimeo', #For vimeo embedding -] +extensions = common_conf.extensions # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/planner/source/conf.py b/planner/source/conf.py index bc911bf604..e8a5c4f086 100644 --- a/planner/source/conf.py +++ b/planner/source/conf.py @@ -31,18 +31,7 @@ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.imgmath', - 'sphinx.ext.ifconfig', - 'sphinxcontrib.youtube', #For youtube embedding - 'sphinxcontrib.vimeo', #For vimeo embedding -] +extensions = common_conf.extensions # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/planner2/source/conf.py b/planner2/source/conf.py index b30d18fb17..77ce8572bd 100644 --- a/planner2/source/conf.py +++ b/planner2/source/conf.py @@ -31,18 +31,7 @@ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.imgmath', - 'sphinx.ext.ifconfig', - 'sphinxcontrib.youtube', #For youtube embedding - 'sphinxcontrib.vimeo', #For vimeo embedding -] +extensions = common_conf.extensions # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/rover/source/conf.py b/rover/source/conf.py index 3f602a0d57..4e545a3e49 100644 --- a/rover/source/conf.py +++ b/rover/source/conf.py @@ -33,18 +33,7 @@ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.imgmath', - 'sphinx.ext.ifconfig', - 'sphinxcontrib.youtube', #For youtube embedding - 'sphinxcontrib.vimeo', #For vimeo embedding -] +extensions = common_conf.extensions # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates']