Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
linw1995 committed May 19, 2019
1 parent 335a98c commit d2f736c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion data_extractor/abc.py
Expand Up @@ -84,7 +84,7 @@ def extract(self, element: Any) -> Any:
:param element: The target data node element.
:returns: Data or subelement
:returns: Data or subelement.
"""
raise NotImplementedError

Expand Down
2 changes: 1 addition & 1 deletion data_extractor/exceptions.py
Expand Up @@ -14,7 +14,7 @@

class ExprError(Exception):
"""
Invalid Expr
Invalid Expr.
:param extractor: The object for data extracting base on :class:`data_extractor.abc.AbstractExtractor`.
:param exc: The actual exception is thrown when extracting.
Expand Down
4 changes: 2 additions & 2 deletions data_extractor/utils.py
Expand Up @@ -7,7 +7,7 @@


class __Sentinel:
""" Singleton """
""" Singleton. """

def __repr__(self) -> str:
return "sentinel"
Expand All @@ -18,7 +18,7 @@ def __repr__(self) -> str:

class LazyStr:
"""
Lazy String
Lazy String.
:param func: Lazy __str__ function.
"""
Expand Down
19 changes: 11 additions & 8 deletions docs/source/quickstarts.rst
Expand Up @@ -4,6 +4,8 @@ Quickstarts
Installation
------------

.. code-block:: shell
pip install data-extractor
Usage
Expand All @@ -17,6 +19,8 @@ HTML or XML data

Download RSS Sample file

.. code-block:: shell
wget http://www.rssboard.org/files/sample-rss-2.xml
Parse it into :class:`data_extractor.lxml.Element`.
Expand All @@ -33,7 +37,7 @@ Using :class:`data_extractor.lxml.XPathExtractor` to extract rss channel title.

.. code-block:: python3
from data_extractor.lxml import XPathExtractor
from data_extractor import XPathExtractor
XPathExtractor("//channel/title/text()").extract_first(root)
Expand All @@ -48,7 +52,7 @@ to extract all rss item links.

.. code-block:: python3
from data_extractor.lxml import TextCSSExtractor
from data_extractor import TextCSSExtractor
TextCSSExtractor("item>link").extract(root)
Expand All @@ -65,7 +69,7 @@ Using :class:`data_extractor.lxml.AttrCSSExtractor` to extract rss version.

.. code-block:: python3
from data_extractor.lxml import AttrCSSExtractor
from data_extractor import AttrCSSExtractor
AttrCSSExtractor("rss", attr="version").extract_first(root)
Expand All @@ -88,7 +92,7 @@ Using :class:`data_extractor.json.JSONExtractor` to extract data.

.. code-block:: python3
from data_extractor.json import JSONExtractor
from data_extractor import JSONExtractor
JSONExtractor("foo[*].baz").extract(data)
Expand All @@ -106,8 +110,7 @@ then extracting the data.

.. code-block:: python3
from data_extractor.item import Field, Item
from data_extractor.lxml import XPathExtractor
from data_extractor import Field, Item, XPathExtractor
class ChannelItem(Item):
title = Field(XPathExtractor("./title/text()"), default="")
Expand All @@ -134,7 +137,7 @@ Extracting the rss data from file

.. code-block:: python3
from data_extractor.lxml import XPathExtractor
from data_extractor import XPathExtractor
Channel(XPathExtractor("//channel")).extract(root)
Expand Down Expand Up @@ -190,7 +193,7 @@ Or just extracting the channel item from file.

.. code-block:: python3
from data_extractor.lxml import XPathExtractor
from data_extractor import XPathExtractor
ChannelItem(XPathExtractor("//channel/item"), is_many=True).extract(root)
Expand Down

0 comments on commit d2f736c

Please sign in to comment.