Skip to content

Commit 200eaf0

Browse files
committed
Update plugin/config docs and experimental plugin entry points. #395
1 parent 4c2df02 commit 200eaf0

19 files changed

+63
-71
lines changed

docs/app.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ An example uWSGI configuration file (probably not idiomatic, from `here`_)::
4040
mount = /reader=reader._app.wsgi:app
4141
plugin = python3
4242
virtualenv = /apps/reader/
43-
env = READER_CONFIG=/apps/reader/reader.yaml
43+
env = READER_CONFIG=/apps/reader/reader.toml
4444

4545

46-
You can also run the web application with the ``serve`` command.
47-
``serve`` uses `Werkzeug's development server`_,
46+
You can also run the web application with the ``web run`` command.
47+
``web run`` uses `Werkzeug's development server`_,
4848
so it probably won't scale well past a single user.
4949

5050
.. note::
@@ -53,14 +53,16 @@ so it probably won't scale well past a single user.
5353
you may want to configure your web server to not send a ``Referer`` header
5454
(by setting ``Referrer-Policy`` header to ``same-origin``
5555
for all responses; `nginx example`_).
56-
The ``serve`` command does it by default.
56+
The ``web run`` command does it by default.
5757

5858

59-
If running on a personal computer, you can use cron to run ``serve`` at boot::
59+
If running on a personal computer, you can use cron to run ``web run`` at boot::
6060

61-
@reboot sleep 60; reader serve -p 8080 2>&1 ) >>"/tmp/$LOGNAME.reader.serve.boot.log"
61+
@reboot sleep 60; reader web run -p 8080 2>&1 ) >>"/tmp/$LOGNAME.reader.web.run.boot.log"
6262

6363

64+
.. FIXME link to new config
65+
6466
.. _here: https://github.com/lemon24/owncloud/blob/b6a6ba28f84fa40a1a822c200c9e245bad84600b/reader.yaml#L77
6567
.. _nginx example: https://github.com/lemon24/owncloud/commit/39c5311d9c0973642d3a7dec73369b3607828fdd#diff-4486765de09ef22bfc83d68c7350a8088db6f2ba35f152f49ee36c8ec5aef03d
6668
.. _Flask documentation: http://flask.pocoo.org/docs/1.0/deploying/

docs/cli.rst

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@
22
Command-line interface
33
======================
44

5-
*reader* comes with a command-line interface
6-
that exposes basic management functionality.
7-
8-
9-
.. warning::
10-
11-
The CLI is is not fully stable,
12-
see the :ref:`roadmap <cli roadmap>` for details.
5+
*reader* comes with a CLI
6+
that exposes management functionality.
137

148
.. note::
159

16-
The command-line interface is optional, use the ``cli`` extra to install
10+
The CLI is optional, use the ``cli`` extra to install
1711
its :ref:`dependencies <Optional dependencies>`.
1812

1913
Most commands need a database to work. The following are equivalent:

docs/config.rst

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ Configuration
33
=============
44

55
Both the :doc:`CLI <cli>` and the :doc:`web application <app>` can
6-
be configured from a file.
7-
8-
.. warning::
9-
10-
The configuration file format is not stable yet
11-
and might change without any notice.
6+
be configured from a TOML file.
127

138
.. note::
149

@@ -21,17 +16,15 @@ The configuration file path can be specified either through the ``--config``
2116
CLI option or through the ``READER_CONFIG`` environment variable
2217
(also usable with the web application).
2318

24-
The config file is split in contexts;
25-
this allows having a set of global defaults
26-
and overriding them with CLI- or web-app-specific values.
27-
Use the ``config dump --merge`` command
28-
to see the final configuration for each context.
29-
30-
The older ``READER_DB``, ``READER_PLUGIN``, and ``READER_APP_PLUGIN``
31-
environment variables always *replace* the corresponding config values,
32-
so they should be used only for debugging.
19+
The configuration file matches the shape of the :doc:`CLI <cli>`
20+
(the ``reader`` section has options for the ``reader`` command,
21+
the ``reader.update`` section has options for the ``reader update`` command, etc.).
22+
In general, option names match those in the CLI
23+
(``--feed-root`` -> ``feed_root``);
24+
options that can be passed multiple times in the CLI
25+
are pluralized in the config
26+
(``--cli-plugin`` -> ``cli_plugins``).
3327

34-
The following example shows the config file structure
35-
and the options currently available:
28+
Example:
3629

3730
.. literalinclude:: ../examples/config.toml

docs/guide.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,8 @@ Plugins
747747
To use a built-in plugin, pass the plugin name to :func:`make_reader`::
748748

749749
>>> reader = make_reader("db.sqlite", plugins=[
750-
... "reader.enclosure_dedupe",
751-
... "reader.entry_dedupe",
750+
... ".enclosure_dedupe",
751+
... ".entry_dedupe",
752752
... ])
753753

754754

docs/plugins.rst

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,30 +100,23 @@ You can still find the code on GitHub:
100100
Loading plugins from the CLI and the web application
101101
----------------------------------------------------
102102

103-
There is experimental support of plugins in the CLI and the web application.
104-
105-
.. warning::
106-
107-
The plugin system/hooks are not stable yet and may change without any notice.
108-
109-
110-
To load plugins, set the ``READER_PLUGIN`` environment variable to the plugin
103+
To load plugins, set the ``READER_PLUGINS`` environment variable to the plugin
111104
entry point (e.g. ``package.module:entry_point``); multiple entry points should
112-
be separated by one space::
105+
be separated by space::
113106

114-
READER_PLUGIN='first.plugin:entry_point second_plugin:main' \
107+
READER_PLUGINS='first.plugin:entry_point second_plugin' \
115108
python -m reader some-command
116109

117-
For `built-in plugins`_, it is enough to use the plugin name (``reader.XYZ``).
110+
For `built-in plugins`_, it is enough to use the plugin name (``.plugin``).
118111

119112
.. note::
120113

121114
:func:`make_reader` ignores the plugin environment variables.
122115

123116

124-
To load web application plugins, set the ``READER_APP_PLUGIN`` environment variable.
117+
To load web application plugins, set the ``READER_WEB_PLUGINS`` environment variable.
125118
To load CLI plugins (that customize the CLI),
126-
set the ``READER_CLI_PLUGIN`` environment variable.
119+
set the ``READER_CLI_PLUGINS`` environment variable.
127120

128121

129122

examples/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ feed_root = "/path/to/feeds"
88
# Options that can be passed multiple times take a list of values
99
# (unlike other settings, plugins are merged with commandline options).
1010
plugins = [
11-
"reader._plugins.sqlite_releases:init",
11+
"reader._plugins.sqlite_releases",
1212
".ua_fallback",
1313
]
1414

src/reader/_plugins/cli_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717
To load::
1818
19-
READER_CLI_PLUGIN='reader._plugins.cli_status.init_cli' \\
19+
READER_CLI_PLUGINS='reader._plugins.cli_status' \\
2020
python -m reader ...
2121
2222
"""

src/reader/_plugins/legacy/enclosure_tags.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
To load::
2121
22-
READER_APP_PLUGIN='reader._plugins.legacy.enclosure_tags:init' \\
22+
READER_WEB_PLUGINS='reader._plugins.legacy.enclosure_tags' \\
2323
python -m reader serve
2424
2525
Implemented for :issue:`50`.
@@ -163,6 +163,6 @@ def enclosure_tags_filter(enclosure, entry, feed_tags):
163163
return [('with tags', url_for('enclosure_tags.enclosure_tags', **args))]
164164

165165

166-
def init(app):
166+
def init_app(app):
167167
app.register_blueprint(blueprint)
168168
app.reader_additional_enclosure_links.append(enclosure_tags_filter)

src/reader/_plugins/legacy/preview_feed_list.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
To load::
1616
17-
READER_APP_PLUGIN='reader._plugins.legacy.preview_feed_list:init' \\
17+
READER_WEB_PLUGINS='reader._plugins.legacy.preview_feed_list' \\
1818
python -m reader serve
1919
2020
Implemented for https://github.com/lemon24/reader/issues/150.
@@ -154,5 +154,5 @@ def handle_parse_error_i_guess(error):
154154
return redirect(url_for('preview_feed_list.feed_list', url=parse_error.url))
155155

156156

157-
def init(app):
157+
def init_app(app):
158158
app.register_blueprint(blueprint)

src/reader/_plugins/legacy/share.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
To load::
88
9-
READER_APP_PLUGIN='reader._plugins.legacy.share:init' \\
9+
READER_WEB_PLUGINS='reader._plugins.legacy.share' \\
1010
python -m reader serve
1111
1212
"""
@@ -49,5 +49,5 @@ def share(entry):
4949
yield name, url
5050

5151

52-
def init(app):
52+
def init_app(app):
5353
app.reader_additional_links.append(share)

0 commit comments

Comments
 (0)