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)
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/
.. _pelican-plugins bug #314: https://github.com/getpelican/pelican-plugins/issues/314
.. _Blinker: https://pythonhosted.org/blinker/

View file

@ -93,21 +93,21 @@ by the ``ghp-import`` command) to the ``elemoine.github.io`` repository's
To publish your Pelican site as User Pages, feel free to adjust the
``github`` target of the Makefile.
Another option for publishing to User Pages is to generate the output files in
the root directory of the project.
For example, your main project folder is ``<username>.github.io`` and you can
create the Pelican project in a subdirectory called ``Pelican``. Then from
inside the ``Pelican`` folder you can run::
$ pelican content -o .. -s pelicanconf.py
Now you can push the whole project ``<username>.github.io`` to the master
branch of your GitHub repository::
$ git push origin master
(assuming origin is set to your remote repository).
Custom 404 Pages
@ -179,4 +179,4 @@ If you are using ``develop-server.sh``, add this to the top::
and modify the ``pelican.server`` line as follows::
$PY -m pelican.server $port --ssl --cert="$CERT" --key="$KEY" &
$PY -m pelican.server $port --ssl --cert="$CERT" --key="$KEY" &