1
0
Fork 0
forked from github/pelican

Convert code in docs to inline literals

Most of the references to code and settings in the docs were wrapped
in single tickmarks (`), while reStructuredText syntax actually calls
for double tickmarks for inline literals, which are normally rendered
as monospaced text with spaces preserved. Converted the relevant
instances to inline literals, along with some other minor fixes.
This commit is contained in:
Justin Mayer 2012-07-01 10:52:39 -07:00
commit 9ad93d36a0
7 changed files with 119 additions and 123 deletions

View file

@ -8,14 +8,14 @@ Is it mandatory to have a configuration file?
No, it's not. Configuration files are just an easy way to configure Pelican.
For basic operations, it's possible to specify options while invoking Pelican
via the command line. See `pelican --help` for more information.
via the command line. See ``pelican --help`` for more information.
I'm creating my own theme. How do I use Pygments for syntax highlighting?
=========================================================================
Pygments adds some classes to the generated content. These classes are used by
themes to style code syntax highlighting via CSS. Specifically, you can
customize the appearance of your syntax highlighting via the `.codehilite pre`
customize the appearance of your syntax highlighting via the ``.codehilite pre``
class in your theme's CSS file. To see how various styles can be used to render
Django code, for example, you can use the demo `on the project website
<http://pygments.org/demo/15101/>`_.
@ -30,7 +30,7 @@ How can I help?
There are several ways to help out. First, you can use Pelican and report any
suggestions or problems you might have on `the bugtracker
<http://github.com/ametaireau/pelican/issues>`_.
<https://github.com/ametaireau/pelican/issues>`_.
If you want to contribute, please fork `the git repository
<https://github.com/ametaireau/pelican/>`_, make your changes, and issue

View file

@ -38,7 +38,7 @@ Upgrading
---------
If you installed a stable Pelican release via pip or easy_install and wish to
upgrade to the latest stable release, you can do so by adding `--upgrade` to
upgrade to the latest stable release, you can do so by adding ``--upgrade`` to
the relevant command. For pip, that would be::
$ pip install --upgrade pelican
@ -55,7 +55,7 @@ At this time, Pelican is dependent on the following Python packages:
* jinja2, for templating support
* docutils, for supporting reStructuredText as an input format
If you're not using Python 2.7, you will also need `argparse`.
If you're not using Python 2.7, you will also need the ``argparse`` package.
Optionally:
@ -73,7 +73,7 @@ file system (for instance, about the category of your articles), but some
information you need to provide in the form of metadata inside your files.
You can provide this metadata in reStructuredText text files via the
following syntax (give your file the `.rst` extension)::
following syntax (give your file the ``.rst`` extension)::
My super title
##############
@ -84,9 +84,9 @@ following syntax (give your file the `.rst` extension)::
:author: Alexis Metaireau
You can also use Markdown syntax (with a file ending in `.md`).
Markdown generation will not work until you explicitly install the `Markdown`
package, which can be done via `pip install Markdown`. Metadata syntax for
You can also use Markdown syntax (with a file ending in ``.md``).
Markdown generation will not work until you explicitly install the ``Markdown``
package, which can be done via ``pip install Markdown``. Metadata syntax for
Markdown posts should follow this pattern::
Date: 2010-12-03
@ -99,17 +99,17 @@ Markdown posts should follow this pattern::
Note that, aside from the title, none of this metadata is mandatory: if the date
is not specified, Pelican will rely on the file's "mtime" timestamp, and the
category can be determined by the directory in which the file resides. For
example, a file located at `python/foobar/myfoobar.rst` will have a category of
`foobar`.
example, a file located at ``python/foobar/myfoobar.rst`` will have a category of
``foobar``.
Generate your blog
------------------
To launch Pelican, just use the `pelican` command::
To launch Pelican, just use the ``pelican`` command::
$ pelican /path/to/your/content/ [-s path/to/your/settings.py]
And… that's all! Your weblog will be generated and saved in the `content/`
And… that's all! Your weblog will be generated and saved in the ``content/``
folder.
The above command will use the default theme to produce a simple site. It's not
@ -123,17 +123,17 @@ the options you can use::
Kickstart a blog
----------------
You also can use the `pelican-quickstart` script to start a new blog in
seconds by just answering a few questions. Just run `pelican-quickstart` and
You also can use the ``pelican-quickstart`` script to start a new blog in
seconds by just answering a few questions. Just run ``pelican-quickstart`` and
you're done! (Added in Pelican 3.0)
Pages
-----
If you create a folder named `pages`, all the files in it will be used to
If you create a folder named ``pages``, all the files in it will be used to
generate static pages.
Then, use the `DISPLAY_PAGES_ON_MENU` setting, which will add all the pages to
Then, use the ``DISPLAY_PAGES_ON_MENU`` setting, which will add all the pages to
the menu.
Importing an existing blog
@ -145,8 +145,8 @@ a simple script. See :ref:`import`.
Translations
------------
It is possible to translate articles. To do so, you need to add a `lang` meta
attribute to your articles/pages and set a `DEFAULT_LANG` setting (which is
It is possible to translate articles. To do so, you need to add a ``lang`` meta
attribute to your articles/pages and set a ``DEFAULT_LANG`` setting (which is
English [en] by default). With those settings in place, only articles with the
default language will be listed, and each article will be accompanied by a list
of available translations for that article.
@ -210,7 +210,7 @@ Auto-reload
It's possible to tell Pelican to watch for your modifications, instead of
manually re-running it every time you want to see your changes. To enable this,
run the `pelican` command with the `-r` or `--autoreload` option.
run the ``pelican`` command with the ``-r`` or ``--autoreload`` option.
Publishing drafts
-----------------
@ -235,4 +235,4 @@ Or run a simple web server using Python::
cd output && python -m SimpleHTTPServer
(Tip: If using the latter method in conjunction with the auto-reload feature,
ensure that `DELETE_OUTPUT_DIRECTORY` is set to `False` in your settings file.)
ensure that ``DELETE_OUTPUT_DIRECTORY`` is set to ``False`` in your settings file.)

View file

@ -12,34 +12,34 @@ original author wrote with some software design information.
Overall structure
=================
What `pelican` does is take a list of files and process them into some
What Pelican does is take a list of files and process them into some
sort of output. Usually, the input files are reStructuredText and Markdown
files, and the output is a blog, but both input and output can be anything you
want.
The logic is separated into different classes and concepts:
* `writers` are responsible for writing files: .html files, RSS feeds, and so
* **Writers** are responsible for writing files: .html files, RSS feeds, and so
on. Since those operations are commonly used, the object is created once and
then passed to the generators.
* `readers` are used to read from various formats (Markdown and
* **Readers** are used to read from various formats (Markdown and
reStructuredText for now, but the system is extensible). Given a file, they return
metadata (author, tags, category, etc.) and content (HTML-formatted).
* `generators` generate the different outputs. For instance, Pelican comes with
`ArticlesGenerator` and `PageGenerator`. Given a configuration, they can do
* **Generators** generate the different outputs. For instance, Pelican comes with
``ArticlesGenerator`` and ``PageGenerator``. Given a configuration, they can do
whatever they want. Most of the time, it's generating files from inputs.
* `pelican` also uses `templates`, so it's easy to write your own theme. The
syntax is `jinja2`, and, trust me, really easy to learn, so don't hesitate
to jump in and build your own theme.
* Pelican also uses templates, so it's easy to write your own theme. The
syntax is `Jinja2 <http://jinja.pocoo.org/>`_ and is very easy to learn, so
don't hesitate to jump in and build your own theme.
How to implement a new reader?
==============================
Is there an awesome markup language you want to add to Pelican?
Well, the only thing you have to do is to create a class with a `read`
Well, the only thing you have to do is to create a class with a ``read``
method that returns HTML content and some metadata.
Take a look at the Markdown reader::
@ -65,8 +65,8 @@ Take a look at the Markdown reader::
Simple, isn't it?
If your new reader requires additional Python dependencies, then you should wrap
their `import` statements in a `try...except` block. Then inside the reader's
class, set the `enabled` class attribute to mark import success or failure.
their ``import`` statements in a ``try...except`` block. Then inside the reader's
class, set the ``enabled`` class attribute to mark import success or failure.
This makes it possible for users to continue using their favourite markup method
without needing to install modules for formats they don't use.
@ -76,17 +76,17 @@ How to implement a new generator?
Generators have two important methods. You're not forced to create
both; only the existing ones will be called.
* `generate_context`, that is called first, for all the generators.
* ``generate_context``, that is called first, for all the generators.
Do whatever you have to do, and update the global context if needed. This
context is shared between all generators, and will be passed to the
templates. For instance, the `PageGenerator` `generate_context` method finds
all the pages, transforms them into objects, and populates the context with
them. Be careful *not* to output anything using this context at this stage,
as it is likely to change by the effect of other generators.
templates. For instance, the ``PageGenerator`` ``generate_context`` method
finds all the pages, transforms them into objects, and populates the context
with them. Be careful *not* to output anything using this context at this
stage, as it is likely to change by the effect of other generators.
* `generate_output` is then called. And guess what is it made for? Oh,
* ``generate_output`` is then called. And guess what is it made for? Oh,
generating the output. :) It's here that you may want to look at the context
and call the methods of the `writer` object that is passed as the first
argument of this function. In the `PageGenerator` example, this method will
and call the methods of the ``writer`` object that is passed as the first
argument of this function. In the ``PageGenerator`` example, this method will
look at all the pages recorded in the global context and output a file on
the disk (using the writer method `write_file`) for each page encountered.
the disk (using the writer method ``write_file``) for each page encountered.

View file

@ -3,14 +3,14 @@
Plugins
#######
Since version 3.0, pelican manages plugins. Plugins are a way to add features
to pelican without having to directly hack pelican code.
Since version 3.0, Pelican manages plugins. Plugins are a way to add features
to Pelican without having to directly hack Pelican code.
Pelican is shipped with a set of core plugins, but you can easily implement
your own (and this page describes how).
How to use plugins?
====================
How to use plugins
==================
To load plugins, you have to specify them in your settings file. You have two
ways to do so.
@ -23,21 +23,21 @@ Or by importing them and adding them to the list::
from pelican.plugins import gravatar
PLUGINS = [gravatar, ]
If your plugins are not in an importable path, you can specify a `PLUGIN_PATH`
If your plugins are not in an importable path, you can specify a ``PLUGIN_PATH``
in the settings::
PLUGIN_PATH = "plugins"
PLUGINS = ["list", "of", "plugins"]
How to create plugins?
======================
How to create plugins
=====================
Plugins are based on the concept of signals. Pelican sends signals and plugins
Plugins are based on the concept of signals. Pelican sends signals, and plugins
subscribe to those signals. The list of signals are defined in a following
section.
The only rule to follow for plugins is to define a `register` callable, in
which you map the signals to your plugin logic. Let's take a simple exemple::
The only rule to follow for plugins is to define a ``register`` callable, in
which you map the signals to your plugin logic. Let's take a simple example::
from pelican import signals
@ -68,7 +68,7 @@ List of plugins
===============
Not all the list are described here, but a few of them have been extracted from
pelican core and provided in pelican.plugins. They are described here:
the Pelican core and provided in ``pelican.plugins``. They are described here:
Tag cloud
---------
@ -82,7 +82,7 @@ Github Activity
This plugin makes use of the ``feedparser`` library that you'll need to
install.
Set the GITHUB_ACTIVITY_FEED parameter to your github activity feed.
Set the ``GITHUB_ACTIVITY_FEED`` parameter to your Github activity feed.
For example, my setting would look like::
GITHUB_ACTIVITY_FEED = 'https://github.com/kpanic.atom'
@ -105,4 +105,4 @@ variable, as in the example::
``github_activity`` is a list of lists. The first element is the title
and the second element is the raw html from github.
and the second element is the raw HTML from Github.

View file

@ -1,40 +1,40 @@
Some history about pelican
Some history about Pelican
##########################
.. warning::
This page comes from a report the original author (Alexis Métaireau) wrote
right after writing pelican, in december 2010. The information may not be
up to date.
right after writing Pelican, in December 2010. The information may not be
up-to-date.
Pelican is a simple static blog generator. It parses markup files
(markdown or restructured text for now), and generate a HTML folder
(Markdown or reStructuredText for now) and generates an HTML folder
with all the files in it.
I've chosen to use python to implement pelican because it seemed to
I've chosen to use Python to implement Pelican because it seemed to
be simple and to fit to my needs. I did not wanted to define a class for
each thing, but still wanted to keep my things loosely coupled.
It turns out that it was exactly what I wanted. From time to time,
thanks to the feedback of some users, it took me a very few time to
provide fixes on it. So far, I've re-factored the pelican code by two
times, each time took less than 30 minutes.
provide fixes on it. So far, I've re-factored the Pelican code by two
times; each time took less than 30 minutes.
Use case
========
I was previously using wordpress, a solution you can host on a web
I was previously using WordPress, a solution you can host on a web
server to manage your blog. Most of the time, I prefer using markup
languages such as Markdown or RestructuredText to type my articles.
languages such as Markdown or reStructuredText to type my articles.
To do so, I use vim. I think it is important to let the people choose the
tool they want to write the articles. In my opinion, a blog manager
should just allow you to take any kind of input and transform it to a
weblog. That's what pelican does.
weblog. That's what Pelican does.
You can write your articles using the tool you want, and the markup
language you want, and then generate a static HTML weblog
language you want, and then generate a static HTML weblog.
.. image:: _static/overall.png
To be flexible enough, pelican have a template support, so you can
easily write you own themes if you want to.
To be flexible enough, Pelican has template support, so you can easily write
your own themes if you want to.
Design process
==============
@ -42,19 +42,18 @@ Design process
Pelican came from a need I have. I started by creating a single file
application, and I have make it grow to support what it does by now.
To start, I wrote a piece of documentation about what I wanted to do.
Then, I have created the content I wanted to parse (the restructured
text files), and started experimenting with the code.
Pelican was 200 lines long, and contained almost ten functions and one
class when it was first usable.
Then, I created the content I wanted to parse (the reStructuredText files)
and started experimenting with the code. Pelican was 200 lines long and
contained almost ten functions and one class when it was first usable.
I have been facing different problems all over the time, and wanted to
add features to pelican while using it. The first change I have done was
I have been facing different problems all over the time and wanted to
add features to Pelican while using it. The first change I have done was
to add the support of a settings file. It is possible to pass the options to
the command line, but can be tedious if there is a lot of them.
In the same way, I have added the support of different things over
time: atom feeds, multiple themes, multiple markup support, etc.
At some point, it appears that the “only one file” mantra was not good
enough for pelican, so I decided to rework a bit all that, and split this in
time: Atom feeds, multiple themes, multiple markup support, etc.
At some point, it appears that the "only one file" mantra was not good
enough for Pelican, so I decided to rework a bit all that, and split this in
multiple different files.
Ive separated the logic in different classes and concepts:
@ -64,59 +63,59 @@ Ive separated the logic in different classes and concepts:
Since those operations are commonly used, the object is created
once, and then passed to the generators.
* *readers* are used to read from various formats (Markdown, and
Restructured Text for now, but the system is extensible). Given a
file, they return metadata (author, tags, category etc) and
content (HTML formated).
* *readers* are used to read from various formats (Markdown and
reStructuredText for now, but the system is extensible). Given a
file, they return metadata (author, tags, category, etc) and
content (HTML formatted).
* *generators* generate the different outputs. For instance, pelican
* *generators* generate the different outputs. For instance, Pelican
comes with an ArticlesGenerator and PagesGenerator, into
others. Given a configuration, they can do whatever you want
them to do. Most of the time its generating files from inputs
them to do. Most of the time it's generating files from inputs
(user inputs and files).
I also deal with contents objects. They can be `Articles`, `Pages`, `Quotes`,
or whatever you want. They are defined in the contents.py module,
and represent some content to be used by the program.
I also deal with contents objects. They can be ``Articles``, ``Pages``,
``Quotes``, or whatever you want. They are defined in the ``contents.py``
module and represent some content to be used by the program.
In more details
===============
In more detail
==============
Here is an overview of the classes involved in pelican.
Here is an overview of the classes involved in Pelican.
.. image:: _static/uml.jpg
The interface do not really exists, and I have added it only to clarify the
whole picture. I do use duck typing, and not interfaces.
The interface does not really exist, and I have added it only to clarify the
whole picture. I do use duck typing and not interfaces.
Internally, the following process is followed:
* First of all, the command line is parsed, and some content from
the user are used to initialize the different generator objects.
the user is used to initialize the different generator objects.
* A `context` is created. It contains the settings from the command
* A ``context`` is created. It contains the settings from the command
line and a settings file if provided.
* The `generate_context` method of each generator is called, updating
* The ``generate_context`` method of each generator is called, updating
the context.
* The writer is created, and given to the `generate_output` method of
* The writer is created and given to the ``generate_output`` method of
each generator.
I make two calls because it is important that when the output is
generated by the generators, the context will not change. In other
words, the first method `generate_context` should modify the context,
whereas the second `generate_output` method should not.
words, the first method ``generate_context`` should modify the context,
whereas the second ``generate_output`` method should not.
Then, it is up to the generators to do what the want, in the
`generate_context` and `generate_content` method.
Taking the `ArticlesGenerator` class will help to understand some others
concepts. Here is what happens when calling the `generate_context`
``generate_context`` and ``generate_content`` method.
Taking the ``ArticlesGenerator`` class will help to understand some others
concepts. Here is what happens when calling the ``generate_context``
method:
* Read the folder “path”, looking for restructured text files, load
each of them, and construct a content object (`Article`) with it. To do so,
use `Reader` objects.
* Update the `context` with all those articles.
each of them, and construct a content object (``Article``) with it. To do so,
use ``Reader`` objects.
* Update the ``context`` with all those articles.
Then, the `generate_content` method uses the `context` and the `writer` to
generate the wanted output
Then, the ``generate_content`` method uses the ``context`` and the ``writer`` to
generate the wanted output.

View file

@ -3,11 +3,10 @@
How to create themes for Pelican
################################
Pelican uses the great `jinja2 <http://jinja.pocoo.org>`_ templating engine to
generate its HTML output. The jinja2 syntax is really simple. If you want to
create your own theme, feel free to take inspiration from the "simple" theme,
which is available `here
<https://github.com/ametaireau/pelican/tree/master/pelican/themes/simple/templates>`_
Pelican uses the great `Jinja2 <http://jinja.pocoo.org/>`_ templating engine to
generate its HTML output. Jinja2 syntax is really simple. If you want to
create your own theme, feel free to take inspiration from the `"simple" theme
<https://github.com/ametaireau/pelican/tree/master/pelican/themes/simple/templates>`_.
Structure
=========

View file

@ -12,16 +12,16 @@ file generator, we can take advantage of this.
User Pages
----------
Github allows you to create user pages in the form of ``username.github.com``.
Whatever is created in master branch will be published. For this purposes just
the output generated by pelican needs to pushed at github.
GitHub allows you to create user pages in the form of ``username.github.com``.
Whatever is created in the master branch will be published. For this purpose,
just the output generated by Pelican needs to pushed to GitHub.
So given a repository containing your articles, just run pelican over the posts
and deploy the master branch at github::
So given a repository containing your articles, just run Pelican over the posts
and deploy the master branch to GitHub::
$ pelican -s pelican.conf.py ./path/to/posts -o /path/to/output
Now add all the files in the output directory generated by pelican::
Now add all the files in the output directory generated by Pelican::
$ git add /path/to/output/*
$ git commit -am "Your Message"
@ -31,12 +31,12 @@ Project Pages
-------------
For creating Project pages, a branch called ``gh-pages`` is used for publishing.
The excellent `ghp-import <https://github.com/davisp/ghp-import>`_ makes this
really easy. You will have to install it::
really easy, which can be installed via::
$ pip install ghp-import
Then, given a repository containing your articles, you would simply have
to run Pelican and upload the output to GitHub::
Then, given a repository containing your articles, you would simply run
Pelican and upload the output to GitHub::
$ pelican -s pelican.conf.py .
$ ghp-import output
@ -45,10 +45,8 @@ to run Pelican and upload the output to GitHub::
And that's it.
If you want, you can put that directly into a post-commit hook, so each time you
commit, your blog is up to date on GitHub!
commit, your blog is up-to-date on GitHub!
Put the following into `.git/hooks/post-commit`::
pelican -s pelican.conf.py . && ghp-import output && git push origin
gh-pages
Put the following into ``.git/hooks/post-commit``::
pelican -s pelican.conf.py . && ghp-import output && git push origin gh-pages