Skip to content

Commit da9b1e0

Browse files
committed
Enable nitpicky Sphinx warnings, fix issues and have the documentation build fail
1 parent ec00965 commit da9b1e0

File tree

8 files changed

+65
-53
lines changed

8 files changed

+65
-53
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ matrix:
2222
env: TOXENV=py37
2323
dist: xenial
2424
sudo: true
25+
- python: 3.7
26+
env: TOXENV=docs
27+
dist: xenial
28+
sudo: true
2529
install:
2630
- |
2731
if [ "$TOXENV" = "pypy" ]; then

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
@@ -857,27 +857,11 @@ There are third-party tools that allow using Parsel from the command line:
857857
.. _cURL: https://curl.haxx.se/
858858

859859

860-
.. _topics-selectors-ref:
861-
862-
API reference
863-
=============
864-
865-
Selector objects
866-
----------------
867-
868-
.. autoclass:: parsel.selector.Selector
869-
:members:
870-
871-
872-
SelectorList objects
873-
--------------------
874-
875-
.. autoclass:: parsel.selector.SelectorList
876-
:members:
877-
878-
879860
.. _selector-examples-html:
880861

862+
Examples
863+
========
864+
881865
Working on HTML
882866
---------------
883867

@@ -936,7 +920,8 @@ Removing namespaces
936920
When dealing with scraping projects, it is often quite convenient to get rid of
937921
namespaces altogether and just work with element names, to write more
938922
simple/convenient XPaths. You can use the
939-
:meth:`Selector.remove_namespaces` method for that.
923+
:meth:`Selector.remove_namespaces <parsel.selector.Selector.remove_namespaces>`
924+
method for that.
940925

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

@@ -947,10 +932,12 @@ Let's download the atom feed using `requests`_ and create a selector::
947932
>>> text = requests.get('https://feeds.feedburner.com/PythonInsider').text
948933
>>> sel = Selector(text=text, type='xml')
949934

950-
This is how the file starts::
935+
This is how the file starts:
936+
937+
.. code-block:: xml
951938
952939
<?xml version="1.0" encoding="UTF-8"?>
953-
<?xml-stylesheet ...
940+
<?xml-stylesheet ... ?>
954941
<feed xmlns="http://www.w3.org/2005/Atom"
955942
xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"
956943
xmlns:blogger="http://schemas.google.com/blogger/2008"
@@ -959,6 +946,7 @@ This is how the file starts::
959946
xmlns:thr="http://purl.org/syndication/thread/1.0"
960947
xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">
961948
...
949+
</feed>
962950
963951
You can see several namespace declarations including a default
964952
"http://www.w3.org/2005/Atom" and another one using the "gd:" prefix for
@@ -970,8 +958,9 @@ We can try selecting all ``<link>`` objects and then see that it doesn't work
970958
>>> sel.xpath("//link")
971959
[]
972960

973-
But once we call the :meth:`Selector.remove_namespaces` method, all
974-
nodes can be accessed directly by their names::
961+
But once we call the :meth:`Selector.remove_namespaces
962+
<parsel.selector.Selector.remove_namespaces>` method, all nodes can be accessed
963+
directly by their names::
975964

976965
>>> sel.remove_namespaces()
977966
>>> 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)