From 48ab9afa69dc7ac08401290c1909711dd9ea1fce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 12 Jul 2015 11:16:38 +0200 Subject: [PATCH 1/2] add external requirements for readthedocs --- requirements.txt | 1 + source/conf.py | 43 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..73f5942ad --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +[-e] git+https://github.com/fabpot/sphinx-php.git@52f7bd2216cc22ef52494f346c5643bb2a74513f diff --git a/source/conf.py b/source/conf.py index d527d1039..51e4e1e77 100644 --- a/source/conf.py +++ b/source/conf.py @@ -28,10 +28,15 @@ if not on_rtd: sys.path.append(os.path.abspath('./../_exts/sphinx-php')) - # adding PhpLexer +# adding PhpLexer +try: from sphinx.highlighting import lexers from pygments.lexers.compiled import CLexer from pygments.lexers.web import PhpLexer + php_lexer_available = True +except ImportError: + php_lexer_available = False + print('specific import not available') # -- General configuration ------------------------------------------------ @@ -46,13 +51,33 @@ extensions = [ 'sphinx.ext.todo', ] -if not on_rtd: - extensions += [ - 'sensio.sphinx.refinclude', - 'sensio.sphinx.configurationblock', - 'sensio.sphinx.phpcode', - 'sensio.sphinx.bestpractice', - ] +try: + import sensio.sphinx.refinclude +except ImportError: + print('sensio.sphinx.refinclude is not available') +else: + extensions += ['sensio.sphinx.refinclude'] + +try: + import sensio.sphinx.configurationblock +except ImportError: + print('sensio.sphinx.configurationblock is not available') +else: + extensions += ['sensio.sphinx.configurationblock'] + +try: + import sensio.sphinx.phpcode +except ImportError: + print('sensio.sphinx.phpcode') +else: + extensions += ['sensio.sphinx.phpcode'] + +try: + import sensio.sphinx.bestpractice +except ImportError: + print('sensio.sphinx.bestpractice is not avaialble') +else: + extensions += ['sensio.sphinx.bestpractice'] #add configuration for api url @@ -122,7 +147,7 @@ pygments_style = 'sphinx' #keep_warnings = False # -- Settings for symfony doc extension --------------------------------------------------- -if not on_rtd: +if php_lexer_available: # enable highlighting for PHP code not between ```` by default lexers['php'] = PhpLexer(startinline=True) lexers['php-annotations'] = PhpLexer(startinline=True) From 7dcb4570501bd8104e9a247149016e43b848f86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Sun, 12 Jul 2015 11:27:21 +0200 Subject: [PATCH 2/2] remove -e option for requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 73f5942ad..b73024f83 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -[-e] git+https://github.com/fabpot/sphinx-php.git@52f7bd2216cc22ef52494f346c5643bb2a74513f +git+https://github.com/fabpot/sphinx-php.git@52f7bd2216cc22ef52494f346c5643bb2a74513f#egg=sphinx-php