From 9cca567bede872ad3383683478f0994576bb8ad5 Mon Sep 17 00:00:00 2001 From: derwinlu Date: Mon, 23 Jan 2017 23:45:08 +0100 Subject: [PATCH 1/6] Add python3.6 test environment * Add py36 environment to tox * Unify dependencies across manual installation and tox * Mention tox in the docs --- docs/contribute.rst | 5 ++++- requirements/developer.pip | 7 ++----- requirements/docs.pip | 2 ++ requirements/style.pip | 2 ++ tox.ini | 11 +++++------ 5 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 requirements/docs.pip create mode 100644 requirements/style.pip diff --git a/docs/contribute.rst b/docs/contribute.rst index 0ed82dfd..1fdc8212 100644 --- a/docs/contribute.rst +++ b/docs/contribute.rst @@ -47,13 +47,16 @@ Or using ``pip``:: $ pip install -e . +To conveniently test vs multiple python versions we also provide a tox file. + + Building the docs ================= If you make changes to the documentation, you should preview your changes before committing them:: - $ pip install sphinx + $ pip install -r requirements/docs.pip $ cd src/pelican/docs $ make html diff --git a/requirements/developer.pip b/requirements/developer.pip index e5507151..5c2f5a69 100644 --- a/requirements/developer.pip +++ b/requirements/developer.pip @@ -1,6 +1,3 @@ -r test.pip - -# Development -flake8 -flake8-import-order -sphinx==1.4.9 +-r docs.pip +-r style.pip diff --git a/requirements/docs.pip b/requirements/docs.pip new file mode 100644 index 00000000..525bdc40 --- /dev/null +++ b/requirements/docs.pip @@ -0,0 +1,2 @@ +sphinx==1.4.9 +sphinx_rtd_theme diff --git a/requirements/style.pip b/requirements/style.pip new file mode 100644 index 00000000..90225d01 --- /dev/null +++ b/requirements/style.pip @@ -0,0 +1,2 @@ +flake8 +flake8-import-order diff --git a/tox.ini b/tox.ini index cb400ea7..95cd5273 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{27,33,34,35},docs,flake8 +envlist = py{27,33,34,35,36},docs,flake8 [testenv] basepython = @@ -7,10 +7,11 @@ basepython = py33: python3.3 py34: python3.4 py35: python3.5 + py36: python3.6 passenv = * usedevelop=True deps = - -rrequirements/developer.pip + -rrequirements/test.pip nose nose-cov coveralls @@ -24,8 +25,7 @@ commands = [testenv:docs] basepython = python2.7 deps = - sphinx==1.4.9 - sphinx_rtd_theme + -rrequirements/docs.pip changedir = docs commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . _build/html @@ -37,8 +37,7 @@ import-order-style = cryptography [testenv:flake8] basepython = python2.7 deps = - flake8 <= 2.4.1 - git+https://github.com/public/flake8-import-order@2ac7052a4e02b4a8a0125a106d87465a3b9fd688 + -rrequirements/style.pip commands = flake8 --version flake8 pelican From a982e0c4f437328f625e45b21762971c4ec94654 Mon Sep 17 00:00:00 2001 From: derwinlu Date: Tue, 24 Jan 2017 00:04:58 +0100 Subject: [PATCH 2/6] Add py36 to travis builds --- .travis.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7bb5a89f..5699cff1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,12 @@ env: - TOX_ENV=py27 - TOX_ENV=py33 - TOX_ENV=py34 + - TOX_ENV=py35 matrix: - include: - - python: 3.5 - env: - - TOX_ENV=py35 + include: + - python: 3.6 + env: + - TOX_ENV=py36 addons: apt_packages: - pandoc From 5a19887a22eedc7060fe39711b383a61f57c4fa2 Mon Sep 17 00:00:00 2001 From: derwinlu Date: Tue, 24 Jan 2017 00:07:15 +0100 Subject: [PATCH 3/6] Correct new flake8 warnings --- pelican/log.py | 1 + pelican/rstdirectives.py | 2 ++ pelican/tools/pelican_quickstart.py | 3 +++ pelican/tools/pelican_themes.py | 1 + 4 files changed, 7 insertions(+) diff --git a/pelican/log.py b/pelican/log.py index cec07bf0..70e069d3 100644 --- a/pelican/log.py +++ b/pelican/log.py @@ -197,6 +197,7 @@ class FatalLogger(LimitLogger): if FatalLogger.errors_fatal: raise RuntimeError('Error encountered') + logging.setLoggerClass(FatalLogger) diff --git a/pelican/rstdirectives.py b/pelican/rstdirectives.py index b52785dd..def67cc7 100644 --- a/pelican/rstdirectives.py +++ b/pelican/rstdirectives.py @@ -70,6 +70,7 @@ class Pygments(Directive): parsed = highlight('\n'.join(self.content), lexer, formatter) return [nodes.raw('', parsed, format='html')] + directives.register_directive('code-block', Pygments) directives.register_directive('sourcecode', Pygments) @@ -90,4 +91,5 @@ def abbr_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): expl = m.group(1) return [abbreviation(abbr, abbr, explanation=expl)], [] + roles.register_local_role('abbr', abbr_role) diff --git a/pelican/tools/pelican_quickstart.py b/pelican/tools/pelican_quickstart.py index 39e58f6f..ae0e8c9d 100755 --- a/pelican/tools/pelican_quickstart.py +++ b/pelican/tools/pelican_quickstart.py @@ -70,6 +70,7 @@ def _input_compat(prompt): r = raw_input(prompt) return r + if six.PY3: str_compat = str else: @@ -81,6 +82,7 @@ else: class _DEFAULT_PATH_TYPE(str_compat): is_default_path = True + _DEFAULT_PATH = _DEFAULT_PATH_TYPE(os.curdir) @@ -412,5 +414,6 @@ needed by Pelican. print('Done. Your new project is available at %s' % CONF['basedir']) + if __name__ == "__main__": main() diff --git a/pelican/tools/pelican_themes.py b/pelican/tools/pelican_themes.py index e4bcb7c9..fd60c424 100755 --- a/pelican/tools/pelican_themes.py +++ b/pelican/tools/pelican_themes.py @@ -14,6 +14,7 @@ def err(msg, die=None): if die: sys.exit((die if type(die) is int else 1)) + try: import pelican except: From dcb6882fbcd243cc146df73b04b1066c332aa9db Mon Sep 17 00:00:00 2001 From: derwinlu Date: Tue, 24 Jan 2017 00:32:37 +0100 Subject: [PATCH 4/6] Update tox to 2.5.0 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5699cff1..f4b68501 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ before_install: - sudo apt-get update -qq - sudo locale-gen fr_FR.UTF-8 tr_TR.UTF-8 install: - - pip install tox==2.0.1 + - pip install tox==2.5.0 script: tox -e $TOX_ENV notifications: irc: From 22208a9471b37a75af113fdede8d9bdb13608f4c Mon Sep 17 00:00:00 2001 From: derwinlu Date: Mon, 23 Jan 2017 23:54:38 +0100 Subject: [PATCH 5/6] Add test checking url replcmnt of unkn. file There was no test case checking the behaviour of what happens when trying to {filename} an unknown file. Also changed the braces to `'` chars that we use elseware. --- pelican/contents.py | 2 +- pelican/tests/test_contents.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pelican/contents.py b/pelican/contents.py index 1ded6cdb..0e842b39 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -246,7 +246,7 @@ class Content(object): origin = origin.replace('\\', '/') # for Windows paths. else: logger.warning( - "Unable to find `%s`, skipping url replacement.", + "Unable to find '%s', skipping url replacement.", value.geturl(), extra={ 'limit_msg': ("Other resources were not found " "and their urls not replaced")}) diff --git a/pelican/tests/test_contents.py b/pelican/tests/test_contents.py index 2f774a6e..29a219f5 100644 --- a/pelican/tests/test_contents.py +++ b/pelican/tests/test_contents.py @@ -731,3 +731,19 @@ class TestStatic(LoggedTestCase): msg="Replacement Indicator 'unknown' not recognized, " "skipping replacement", level=logging.WARNING) + + def test_link_to_unknown_file(self): + "{filename} link to unknown file should trigger warning." + + html = 'link' + page = Page(content=html, + metadata={'title': 'fakepage'}, settings=self.settings, + source_path=os.path.join('dir', 'otherdir', 'fakepage.md'), + context=self.context) + content = page.get_content('') + + self.assertEqual(content, html) + self.assertLogCountEqual( + count=1, + msg="Unable to find 'foo', skipping url replacement.", + level=logging.WARNING) From 490e3646ba4274a60e261319e5ce42235f6a3696 Mon Sep 17 00:00:00 2001 From: derwinlu Date: Mon, 27 Feb 2017 22:29:27 +0100 Subject: [PATCH 6/6] Implement review feedback * improve wording on testing with fox (contribute.rst) * fix whitespace (.travis.xml) --- .travis.yml | 8 ++++---- docs/contribute.rst | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index f4b68501..a7a8732d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,10 @@ env: - TOX_ENV=py34 - TOX_ENV=py35 matrix: - include: - - python: 3.6 - env: - - TOX_ENV=py36 + include: + - python: 3.6 + env: + - TOX_ENV=py36 addons: apt_packages: - pandoc diff --git a/docs/contribute.rst b/docs/contribute.rst index 1fdc8212..187c3007 100644 --- a/docs/contribute.rst +++ b/docs/contribute.rst @@ -47,7 +47,7 @@ Or using ``pip``:: $ pip install -e . -To conveniently test vs multiple python versions we also provide a tox file. +To conveniently test on multiple Python versions, we also provide a .tox file. Building the docs