Skip to content

Commit 3571df4

Browse files
authored
Merge pull request #156 from Gallaecio/documentation-build
Enable nitpicky Sphinx warnings, fix issues and fail on new issues
2 parents 8e1eaab + 7fc25db commit 3571df4

File tree

8 files changed

+66
-73
lines changed

8 files changed

+66
-73
lines changed

.travis.yml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ matrix:
88
include:
99
- python: 2.7
1010
env: TOXENV=py27
11-
- python: 2.7
11+
- python: pypy
1212
env: TOXENV=pypy
13-
- python: 2.7
14-
env: TOXENV=pypy3
1513
- python: 3.4
1614
env: TOXENV=py34
1715
- python: 3.5
@@ -20,24 +18,11 @@ matrix:
2018
env: TOXENV=py36
2119
- python: 3.7
2220
env: TOXENV=py37
23-
dist: xenial
24-
sudo: true
21+
- python: pypy3
22+
env: TOXENV=pypy3
23+
- python: 3.7
24+
env: TOXENV=docs
2525
install:
26-
- |
27-
if [ "$TOXENV" = "pypy" ]; then
28-
export PYPY_VERSION="pypy-6.0.0-linux_x86_64-portable"
29-
wget "https://bitbucket.org/squeaky/portable-pypy/downloads/${PYPY_VERSION}.tar.bz2"
30-
tar -jxf ${PYPY_VERSION}.tar.bz2
31-
virtualenv --python="$PYPY_VERSION/bin/pypy" "$HOME/virtualenvs/$PYPY_VERSION"
32-
source "$HOME/virtualenvs/$PYPY_VERSION/bin/activate"
33-
fi
34-
if [ "$TOXENV" = "pypy3" ]; then
35-
export PYPY_VERSION="pypy3.5-6.0.0-linux_x86_64-portable"
36-
wget "https://bitbucket.org/squeaky/portable-pypy/downloads/${PYPY_VERSION}.tar.bz2"
37-
tar -jxf ${PYPY_VERSION}.tar.bz2
38-
virtualenv --python="$PYPY_VERSION/bin/pypy3" "$HOME/virtualenvs/$PYPY_VERSION"
39-
source "$HOME/virtualenvs/$PYPY_VERSION/bin/activate"
40-
fi
4126
- pip install -U pip tox twine wheel codecov
4227
script: tox
4328
after_success:

docs/conf.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040

4141
# Add any Sphinx extension module names here, as strings. They can be
4242
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
43-
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
43+
extensions = [
44+
'sphinx.ext.autodoc',
45+
'sphinx.ext.intersphinx',
46+
'sphinx.ext.viewcode',
47+
]
4448

4549
# Add any paths that contain templates here, relative to this directory.
4650
templates_path = ['_templates']
@@ -273,3 +277,22 @@
273277

274278
# If true, do not generate a @detailmenu in the "Top" node's menu.
275279
#texinfo_no_detailmenu = False
280+
281+
282+
# -- Options for the InterSphinx extension ------------------------------------
283+
284+
intersphinx_mapping = {
285+
'cssselect': ('https://cssselect.readthedocs.io/en/latest', None),
286+
'python': ('https://docs.python.org/3', None),
287+
}
288+
289+
290+
# --- Nitpicking options ------------------------------------------------------
291+
292+
nitpicky = True
293+
nitpick_ignore = [
294+
('py:class', 'cssselect.xpath.GenericTranslator'),
295+
('py:class', 'cssselect.xpath.HTMLTranslator'),
296+
('py:class', 'cssselect.xpath.XPathExpr'),
297+
('py:class', 'lxml.etree.XMLParser'),
298+
]

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Contents:
1515

1616
installation
1717
usage
18+
parsel
1819
history
1920

2021
Indices and tables

docs/modules.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/parsel.rst

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
1-
parsel package
2-
==============
1+
API reference
2+
=============
33

4-
Submodules
5-
----------
6-
7-
parsel.csstranslator module
8-
---------------------------
4+
parsel.csstranslator
5+
--------------------
96

107
.. automodule:: parsel.csstranslator
118
:members:
129
:undoc-members:
1310
:show-inheritance:
1411

15-
parsel.selector module
16-
----------------------
1712

18-
.. automodule:: parsel.selector
19-
:members:
20-
:undoc-members:
21-
:show-inheritance:
13+
.. _topics-selectors-ref:
2214

23-
parsel.utils module
24-
-------------------
15+
parsel.selector
16+
---------------
2517

26-
.. automodule:: parsel.utils
18+
.. automodule:: parsel.selector
2719
:members:
2820
:undoc-members:
2921
:show-inheritance:
3022

3123

32-
Module contents
33-
---------------
24+
parsel.utils
25+
------------
3426

35-
.. automodule:: parsel
27+
.. automodule:: parsel.utils
3628
:members:
3729
:undoc-members:
3830
:show-inheritance:

docs/readme.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/usage.rst

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -886,27 +886,11 @@ There are third-party tools that allow using Parsel from the command line:
886886
.. _cURL: https://curl.haxx.se/
887887

888888

889-
.. _topics-selectors-ref:
890-
891-
API reference
892-
=============
893-
894-
Selector objects
895-
----------------
896-
897-
.. autoclass:: parsel.selector.Selector
898-
:members:
899-
900-
901-
SelectorList objects
902-
--------------------
903-
904-
.. autoclass:: parsel.selector.SelectorList
905-
:members:
906-
907-
908889
.. _selector-examples-html:
909890

891+
Examples
892+
========
893+
910894
Working on HTML
911895
---------------
912896

@@ -965,7 +949,8 @@ Removing namespaces
965949
When dealing with scraping projects, it is often quite convenient to get rid of
966950
namespaces altogether and just work with element names, to write more
967951
simple/convenient XPaths. You can use the
968-
:meth:`Selector.remove_namespaces` method for that.
952+
:meth:`Selector.remove_namespaces <parsel.selector.Selector.remove_namespaces>`
953+
method for that.
969954

970955
Let's show an example that illustrates this with the Python Insider blog atom feed.
971956

@@ -976,10 +961,12 @@ Let's download the atom feed using `requests`_ and create a selector::
976961
>>> text = requests.get('https://feeds.feedburner.com/PythonInsider').text
977962
>>> sel = Selector(text=text, type='xml')
978963

979-
This is how the file starts::
964+
This is how the file starts:
965+
966+
.. code-block:: xml
980967
981968
<?xml version="1.0" encoding="UTF-8"?>
982-
<?xml-stylesheet ...
969+
<?xml-stylesheet ... ?>
983970
<feed xmlns="http://www.w3.org/2005/Atom"
984971
xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"
985972
xmlns:blogger="http://schemas.google.com/blogger/2008"
@@ -988,6 +975,7 @@ This is how the file starts::
988975
xmlns:thr="http://purl.org/syndication/thread/1.0"
989976
xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">
990977
...
978+
</feed>
991979
992980
You can see several namespace declarations including a default
993981
"http://www.w3.org/2005/Atom" and another one using the "gd:" prefix for
@@ -999,8 +987,9 @@ We can try selecting all ``<link>`` objects and then see that it doesn't work
999987
>>> sel.xpath("//link")
1000988
[]
1001989

1002-
But once we call the :meth:`Selector.remove_namespaces` method, all
1003-
nodes can be accessed directly by their names::
990+
But once we call the :meth:`Selector.remove_namespaces
991+
<parsel.selector.Selector.remove_namespaces>` method, all nodes can be accessed
992+
directly by their names::
1004993

1005994
>>> sel.remove_namespaces()
1006995
>>> sel.xpath("//link")

tox.ini

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,15 @@ deps =
66
-r{toxinidir}/tests/requirements.txt
77

88
commands = py.test --cov=parsel --cov-report= {posargs:parsel tests}
9+
10+
[docs]
11+
changedir = docs
12+
deps =
13+
sphinx
14+
sphinx_rtd_theme
15+
16+
[testenv:docs]
17+
changedir = {[docs]changedir}
18+
deps = {[docs]deps}
19+
commands =
20+
sphinx-build -W -b html . {envtmpdir}/html

0 commit comments

Comments
 (0)