Merge pull request #2901 from MinchinWeb/writer-docs

Document how to add a new writer
This commit is contained in:
Justin Mayer 2021-07-13 09:33:34 +02:00 committed by GitHub
commit 0919507ae7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 5 deletions

View file

@ -274,6 +274,33 @@ Adding a new generator is also really easy. You might want to have a look at
signals.get_generators.connect(get_generators) signals.get_generators.connect(get_generators)
Adding a new writer
-------------------
Adding a writer will allow you to output additional file formats to disk, or
change how the existing formats are written to disk. Note that only one writer
will be active at a time, so be sure to either subclass the built-in Writer, or
completely re-implement it.
Here is a basic example of how to set up your own writer::
from pelican.writers import Writer
from pelican import signals
class MyWriter(Writer):
# define new writer functionality
pass
def add_writer(pelican_object):
# use pelican_instance to setup stuff if needed
return MyWriter
def register():
signals.get_writer.connect(add_writer)
.. _Pip: https://pip.pypa.io/ .. _Pip: https://pip.pypa.io/
.. _pelican-plugins bug #314: https://github.com/getpelican/pelican-plugins/issues/314 .. _pelican-plugins bug #314: https://github.com/getpelican/pelican-plugins/issues/314
.. _Blinker: https://pythonhosted.org/blinker/ .. _Blinker: https://pythonhosted.org/blinker/