Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Fixed inconsistent examples #199

Closed
wants to merge 10 commits into from
22 changes: 15 additions & 7 deletions docs/source/item-validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ that need to be validated.

# settings.py

SPIDERMON_VALIDATION_MODELS: [
'myproject.spiders.validators.DummyItemModel'
SPIDERMON_VALIDATION_MODELS = [
'tutorial.validators.DummyItemModel'
]

If you are working on a spider that produces multiple items types, you can define it
Expand All @@ -157,9 +157,13 @@ as a `dict`:

# settings.py

SPIDERMON_VALIDATION_MODELS: {
DummyItem: 'myproject.spiders.validators.DummyItemModel',
OtherItem: 'myproject.spiders.validators.OtherItemModel',
from tutorial.items import DummyItem, OtherItem

...

SPIDERMON_VALIDATION_MODELS = {
DummyItem: 'tutorial.validators.DummyItemModel',
OtherItem: 'tutorial.validators.OtherItemModel',
}

.. _SPIDERMON_VALIDATION_SCHEMAS:
Expand All @@ -175,7 +179,7 @@ A `list` containing the location of the item schema. Could be a local path or a

# settings.py

SPIDERMON_VALIDATION_SCHEMAS: [
SPIDERMON_VALIDATION_SCHEMAS = [
'/path/to/schema.json',
's3://bucket/schema.json',
'https://example.com/schema.json',
Expand All @@ -188,7 +192,11 @@ as a `dict`:

# settings.py

SPIDERMON_VALIDATION_SCHEMAS: {
from tutorial.items import DummyItem, OtherItem

...

SPIDERMON_VALIDATION_SCHEMAS = {
DummyItem: '/path/to/dummyitem_schema.json',
OtherItem: '/path/to/otheritem_schema.json',
}
Expand Down
10 changes: 5 additions & 5 deletions docs/source/monitors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ First we define a new action that will close the spider when executed:

.. code-block:: python

# myproject/actions.py
# tutorial/actions.py
from spidermon.core.actions import Action

class CloseSpiderAction(Action):
Expand All @@ -180,8 +180,8 @@ and then take an action if it fails:

.. code-block:: python

# myproject/monitors.py
from myproject.actions import CloseSpiderAction
# tutorial/monitors.py
from tutorial.actions import CloseSpiderAction

@monitors.name('Periodic job stats monitor')
class PeriodicJobStatsMonitor(Monitor, StatsMonitorMixin):
Expand All @@ -202,10 +202,10 @@ The last step is to configure the suite to be executed every 60 seconds:

.. code-block:: python

# myproject/settings.py
# tutorial/settings.py

SPIDERMON_PERIODIC_MONITORS = {
'myproject.monitors.PeriodicMonitorSuite': 60, # time in seconds
'tutorial.monitors.PeriodicMonitorSuite': 60, # time in seconds
}

What to monitor?
Expand Down
2 changes: 1 addition & 1 deletion docs/source/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ For example, the following suite will be executed every 30 minutes:
.. code-block:: python

SPIDERMON_PERIODIC_MONITORS = {
'myproject.monitors.PeriodicMonitorSuite': 1800,
'tutorial.monitors.PeriodicMonitorSuite': 1800,
}

.. _SPIDERMON_SPIDER_CLOSE_MONITORS:
Expand Down
4 changes: 2 additions & 2 deletions docs/source/stats-collection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To enable it, include the following code in your project settings:

.. code-block:: python

# myproject/settings.py
# tutorial/settings.py
STATS_CLASS = (
"spidermon.contrib.stats.statscollectors.LocalStorageStatsHistoryCollector"
)
Expand All @@ -34,7 +34,7 @@ returned in the previous spider executions.

.. code-block:: python

# myproject/monitors.py
# tutorial/monitors.py
from spidermon import Monitor, MonitorSuite, monitors


Expand Down