-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
452 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,4 +129,6 @@ dmypy.json | |
.pyre/ | ||
|
||
.envrc | ||
.idea | ||
.idea | ||
|
||
_collections/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
function | ||
======== | ||
|
||
Executes a function referenced by ``source`` and writes its return value into a file specified by ``target``. | ||
|
||
.. code-block:: python | ||
def my_own_data(config): | ||
string = 'This data gets written into {}'.format(config['target']) | ||
return string | ||
collections = { | ||
'my_files: { | ||
'driver': 'function', | ||
'source': my_own_data, | ||
'target': 'my_data/my_file.txt' | ||
'write_result': True | ||
} | ||
} | ||
} | ||
The specified function gets 1 argument during the call: A dictionary which contains the complete configuration of the | ||
collection. | ||
|
||
If return value is not None, the returned data is written to the file specified by ``target``. | ||
|
||
Options | ||
------- | ||
|
||
write_result | ||
~~~~~~~~~~~~ | ||
|
||
If ``write_result`` is False, no data is written by the driver. | ||
But this could be done by the function itself. | ||
|
||
**Default**: ``True`` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
report | ||
====== | ||
|
||
Creates a collection report in file specified by ``target``. | ||
|
||
Please be sure to specify this report as one of the latest collections, otherwise other | ||
collections have not been executed before this report gets generated. | ||
|
||
.. code-block:: python | ||
collections = { | ||
'my_collection_report: { | ||
'driver': 'report', | ||
'target': 'reports/collections.rst' | ||
} | ||
} | ||
} | ||
The following template is used to build the report: | ||
|
||
.. literalinclude:: ../../sphinxcontrib/collections/drivers/report.rst.template | ||
|
||
**Example**: | ||
|
||
This is the report of the latest run for this documentation. | ||
|
||
.. literalinclude:: /_collections/doc_collection_report.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
string | ||
====== | ||
|
||
Copies a string defined in ``source`` into a file specified by ``target``. | ||
|
||
.. code-block:: python | ||
collections = { | ||
'my_files: { | ||
'driver': 'string', | ||
'source': 'Awesome, this is nice', | ||
'target': 'my_data/my_file.txt' | ||
} | ||
} | ||
} | ||
You can also use more complex strings by assigning them to a variable. | ||
|
||
.. code-block:: python | ||
my_string = """ | ||
Headline | ||
======== | ||
Ohh **awesome**! | ||
Multiline! | ||
.. codeblock:: rst | ||
Works also | ||
---------- | ||
""" | ||
collections = { | ||
'my_files: { | ||
'driver': 'string', | ||
'source': my_string, | ||
'target': 'my_data/my_file.txt' | ||
} | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from sphinxcontrib.collections.collections import setup # NOQA | ||
from sphinxcontrib.collections.main import setup # NOQA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from sphinxcontrib.collections.collections import DRIVERS | ||
from sphinxcontrib.collections.drivers import Driver | ||
|
||
|
||
def register_driver(name, driver_class): | ||
if not issubclass(driver_class, Driver): | ||
raise SphinxCollectionsApiError('Given driver class must be a subclass of the main Driver class.') | ||
|
||
try: | ||
DRIVERS[name] = driver_class | ||
except KeyError: | ||
raise SphinxCollectionsApiError('Driver with name {} already exists.'.format(name)) | ||
|
||
|
||
class SphinxCollectionsApiError(BaseException): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.