diff --git a/README b/README
index ce0bf7f..30ece75 100644
--- a/README
+++ b/README
@@ -1,6 +1,117 @@
-reStructuredWeb -- static site generator.
+=====
+[rSW]
+=====
+
+reStructuredWeb (rSW, reSW or rstW) -- is a highly customizable static site
+generator for the reStructuredText markup language.
Docs:
-* https://nixhacks.net/rstw/
-* https://git/nxhs.cloud/ge/rstw_docs/
+* https://nixhacks.net/rsw/
+* https://git.nxhs.cloud/ge/rSW/src/branch/master/docs
+
+Installation
+============
+
+From PyPI
+---------
+
+::
+
+ pip install reSW
+
+From tarball
+------------
+
+::
+
+ pip install ./reSW-0.1.2.tar.gz
+
+Shell completion
+----------------
+
+::
+
+ pip install infi.docopt-completion
+ docopt-completion rsw
+
+Quick start
+===========
+
+1. Initialise site with following commands::
+
+ rsw init my_site
+ cd my_site
+
+2. Create first template and post.
+
+ Template layouts/template.jinja2::
+
+
+
+
+
+ {{ page.title }}
+
+
+ {{ html | safe }}
+
+
+
+ Post content/index.rst::
+
+ :title: Hello, World!
+ :date: 1970-01-01
+
+ =============
+ Hello, World!
+ =============
+
+ Hello, there! This is my first site built with *re*\ **Structured**\ *Web*!
+
+3. Build your site::
+
+ rsw build
+
+Command Line Interface
+======================
+
+::
+
+ Usage: rsw init [--no-makefile] []
+ rsw build [-c ]
+ rsw print [-c ] [--default] [--json]
+ rsw (-h | --help | -v | --version)
+
+ Commands:
+ init initialise new site.
+ build build site.
+ print print configuration.
+
+ Options:
+ -c , --config configuaration file.
+ -j, --json JSON output.
+ -d, --default print default config.
+ -M, --no-makefile do not create Makefile.
+ -h, --help print this help message and exit.
+ -v, --version print version and exit.
+
+Development
+===========
+
+Build Python package
+--------------------
+
+Variant 1::
+
+ pip install setuptools wheel twine
+ python setup.py sdist bdist_wheel
+
+Variant 2::
+
+ pip install -U build
+ python -m build
+
+Via Makefile (`build` package needed)::
+
+ make build
diff --git a/docs/.gitignore b/docs/.gitignore
new file mode 100644
index 0000000..dcb58ba
--- /dev/null
+++ b/docs/.gitignore
@@ -0,0 +1,2 @@
+build/
+downloads/
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..f346fac
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,36 @@
+# Makefile for reSW
+
+CONTENTDIR = content
+STATICDIR = static
+BUILDDIR = build
+CONFIG = settings.toml
+
+all: build
+
+help:
+ @echo 'Build rSW site'
+ @echo
+ @echo 'Available targets:'
+ @echo
+ @echo ' build build HTML'
+ @echo ' serve run local HTTP server'
+ @echo ' css generate Pygments stylesheet'
+ @echo
+ @echo 'Run make without target to build html'
+
+build:
+ test -d "$(BUILDDIR)" && rm -rf "$(BUILDDIR)" || true
+ rsw build -c "$(CONFIG)"
+
+serve:
+ python -m http.server --directory $(BUILDDIR)/ --bind 0.0.0.0 8080
+
+css:
+ mkdir -pv "$(STATICDIR)"/css/pygments
+ pygmentize -f html -S $(filter-out $@,$(MAKECMDGOALS)) -a .highlight \
+ > "$(STATICDIR)"/css/pygments/$(filter-out $@,$(MAKECMDGOALS)).css
+
+%:
+ @:
+
+.PHONY: all help build serve css
diff --git a/docs/content/cli.rst b/docs/content/cli.rst
new file mode 100644
index 0000000..82e5d67
--- /dev/null
+++ b/docs/content/cli.rst
@@ -0,0 +1,39 @@
+:title: Command Line Interface
+:date: 2022-09-30
+
+======================
+Command Line Interface
+======================
+
+::
+
+ Usage: rsw init [--no-makefile] []
+ rsw build [-c ]
+ rsw print [-c ] [--default] [--json]
+ rsw (-h | --help | -v | --version)
+
+ Commands:
+ init initialise new site.
+ build build site.
+ print print configuration.
+
+ Options:
+ -c , --config configuaration file.
+ -j, --json JSON output.
+ -d, --default print default config.
+ -M, --no-makefile do not create Makefile.
+ -h, --help print this help message and exit.
+ -v, --version print version and exit.
+
+Makefile usage
+==============
+
+::
+
+ Available targets:
+
+ build build HTML
+ serve run local HTTP server
+ css generate Pygments stylesheet
+
+ Run make without target to build html
diff --git a/docs/content/configuration.rst b/docs/content/configuration.rst
new file mode 100644
index 0000000..cb481d7
--- /dev/null
+++ b/docs/content/configuration.rst
@@ -0,0 +1,71 @@
+:title: Configuration
+:date: 2022-09-22
+
+=============
+Configuration
+=============
+
+Dirs (``dirs``)
+===============
+
+build_dir
+ Default: build
+
+content_dir
+ Default: content
+
+templates_dir
+ Default: layouts
+
+static_dir
+ Default: static
+
+ .. note::
+
+ Content of this diretory will be placed into site root. Use
+ subdirectories for files here, e.g. css/, img/, etc.
+
+Default settings for pages (``defaults``)
+=========================================
+
+template
+ Default: template.jinja2
+
+ Default page template.
+
+type
+ Default: page
+
+ Default article type.
+
+Custom site data (``site``)
+===========================
+
+datetime_format
+ Default: %Y-%m-%d
+
+ See `Format Codes`_.
+
+Pygments (``pygments``)
+=======================
+
+theme
+ Default: default
+
+ Generate CSS style with following command::
+
+ make css style_name
+
+ See `Pygments Styles`_ and `pygmentize`_.
+
+Docutils (``docutils``)
+=======================
+
+See `Docutils Configuration`_.
+
+.. Links
+
+.. _Format Codes: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes
+.. _Pygments Styles: https://pygments.org/styles/
+.. _pygmentize: https://pygments.org/docs/cmdline/
+.. _Docutils Configuration: https://docutils.sourceforge.io/docs/user/config.html
diff --git a/docs/content/data_sources.rst b/docs/content/data_sources.rst
new file mode 100644
index 0000000..cb9bf8a
--- /dev/null
+++ b/docs/content/data_sources.rst
@@ -0,0 +1,114 @@
+:title: Data Sources
+:date: 2022-09-22
+
+============
+Data Sources
+============
+
+The diagram below shows the data sources and variables that can be used in
+templates.
+
+::
+
+ ┌─────────────────┐
+ │ settings.toml ├───► site, pygments_theme ──┐
+ └─────────────────┘ │
+ │
+ ┌─────────────────┐ ┌────────▼────────┐
+ │ *.rst ├───► page, html ───► template.jinja2 │
+ └────────┬────────┘ └────────▲────────┘
+ │ │
+ ┌────────▼────────┐ │
+ │ Aggregated data ├───► aggr ──────────────────┘
+ └─────────────────┘
+
+\*.rst Files
+============
+
+The \*.rst files contain a part with document attributes called Docinfo (see
+`field lists`_ and `bibliographic elements`_) and a part with the content of
+the article.
+
+You can come up with your own attributes. Attributes can contain only strings.
+
+There some special attributes used by rSW:
+
+============ =============== =========================
+Attribute Required Deafult
+============ =============== =========================
+``type`` No page
+``template`` No template.jinja2
+``date`` Yes None
+``title`` No None
+============ =============== =========================
+
+type
+ Article type. Can be post for blog posts or ``page`` for standalone
+ pages.
+
+template
+ The template to be used when rendering the HTML page.
+
+ The attribute value must be the path to the template file relative to the
+ template directory. For example, the templates/index.jinja2 file would be:
+
+ .. code-block:: rst
+
+ :template: index.jinja2
+
+ The path to the templates directory and default template can be overridden
+ in **settings.toml**.
+
+date
+ Date in ISO format YYYY-MM-DD. This attribute is used to sort the list of
+ posts. The date format can be overridden in **settings.toml**.
+
+title
+ Title of the article. It is not required and is not processed by rSW in
+ any way, but it is desirable to fill it for use in templates.
+
+.. note::
+
+ The ``authors`` attribute is `special`_ and is not yet supported by rSW.
+ Using ``authors`` will result in an error when building the site.
+
+settings.toml
+=============
+
+The configuration file has a special ``site`` section, all data from which is
+passed to the template unchanged.
+
+The structure and data types can be arbitrary. The file uses the
+`TOML `_ format.
+
+For example, in this way you can pass basic information about the site:
+
+.. code-block:: toml
+
+ [site]
+ title = 'My site'
+ name = 'My awesome site'
+ description = 'Awesome site about awesome things'
+ datetime_format = '%d %b %Y'
+
+A special variable ``pygments_theme`` is also passed to the template from the
+configuration file. It contains the value of ``pygments.theme``.
+
+Aggregated data
+===============
+
+A dictionary with aggregated data. This data is collected during site
+generation before HTML-pages are rendered.
+
+Aggregated data contains lists of blog posts and standalone pages.
+
+The list of posts is sorted in descending order by date from the ``date``
+attribute.
+
+The next article will describe the use of this data in templates.
+
+.. Links
+
+.. _field lists: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html\#field-lists
+.. _bibliographic elements: https://docutils.sourceforge.io/docs/ref/doctree.html#bibliographic-elements
+.. _special: https://docutils.sourceforge.io/docs/ref/doctree.html#authors
diff --git a/docs/content/examples.rst b/docs/content/examples.rst
new file mode 100644
index 0000000..0b09647
--- /dev/null
+++ b/docs/content/examples.rst
@@ -0,0 +1,199 @@
+:title: Examples
+:date: 2022-09-30
+
+========
+Examples
+========
+
+Blog site example
+=================
+
+For the blog, we will need to create three template files and at least two
+.rst files.
+
+Edit your **settings.toml**:
+
+.. code-block:: toml
+
+ [defaults]
+ template = 'post.jinja2'
+ type = 'post'
+
+ [site]
+ title = 'My Blog'
+
+Generate Pygments theme:
+
+.. code-block:: shell
+
+ make css default
+
+Create basic template **layouts/base.jinja2**:
+
+.. code-block:: jinja
+
+
+
+
+
+
+
+ {{ page.title }} | {{ site.title }}
+
+
+ {% block content %}{% endblock %}
+
+
+
+Home page template **layouts/index.jinja2**:
+
+.. code-block:: jinja
+
+ {% extends "base.jinja2" %}
+ {% block content %}
+
+
+ {# Page content #}
+
+ {{ html | safe }}
+
+
+ {# Pagination #}
+ {% for item in site.sidebar %}
+ {% if item.title == page.title %}
+ {% set current = site.sidebar.index(item) %}
+ {% set last = site.sidebar.index(site.sidebar[-1]) %}
+ {% if current == 0 %}
+ {# If curret page is a first page #}
+
+ {{ site.sidebar[current+1].title }} -->
+ {% elif current == last %}
+ {# If curret page is a last page #}
+
+ <-- {{ site.sidebar[current-1].title }}
+ {% else %}
+
+ <-- {{ site.sidebar[current-1].title }}
+
+ {{ site.sidebar[current+1].title }} -->
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+
+**content/index.rst**:
+
+.. code-block:: rst
+
+ :title: Homepage
+ :date: 1907-01-01
+
+ =======
+ Welcome
+ =======
+
+ Hello, there!
+
+Page example e.g. **content/first.rst**:
+
+.. code-block:: rst
+
+ :title: First
+ :date: 1907-01-01
+
+ =====
+ First
+ =====
+
+ First page.
+
+.. note::
+
+ Page ``:title:`` and sidebar's ``title`` in **settings.toml** item must be
+ the same. Otherwise pagination not be displayed.
diff --git a/docs/content/index.rst b/docs/content/index.rst
new file mode 100644
index 0000000..f228af4
--- /dev/null
+++ b/docs/content/index.rst
@@ -0,0 +1,52 @@
+:title: reStructuredWeb
+:date: 2022-09-22
+
+|rSW|
+
+v0.1.2
+
+reStructuredWeb (rSW, reSW or rstW) — is a highly customizable static site
+generator for the *re*\ **Structured**\ *Text* markup language.
+
+Why another site generator?
+===========================
+
+Hundreds of static site generators have been written with varying degrees of
+shittyness. Here are just some of the shortcomings of existing solutions:
+
+* Bad customization. If the task requires something that is not provided for
+ in regular themes, then you have to strain. Editing a theme is an adventure.
+* Some of the solutions are extremely primitive and only fit narrow cases.
+ Others, on the contrary, are overcomplicated.
+* There are very few generators with reStructuredText support.
+
+Why is reStructuredWeb better?
+==============================
+
+* **Small codebase**. About ~300 lines in total.
+* **Doesn't depend on the presentation layer**. rSW just takes data from
+ files and allows you to insert it into templates.
+
+That's all. In fact, this is enough for a static site generator.
+
+**rSW** is built on |Docutils|_ and |Jinja2|_.
+
+.. |rSW| image::
+ /rsw/img/rsw.svg
+ :alt: [rSW]
+ :align: middle
+ :height: 3em
+
+.. |Docutils| image::
+ /rsw/img/rst.png
+ :alt: Docutils
+ :align: middle
+ :width: 7em
+.. _Docutils: https://docutils.sourceforge.io/
+
+.. |Jinja2| image::
+ /rsw/img/jinja.png
+ :alt: Jinja2
+ :align: middle
+ :width: 3em
+.. _Jinja2: https://jinja.palletsprojects.com/
diff --git a/docs/content/install.rst b/docs/content/install.rst
new file mode 100644
index 0000000..e020870
--- /dev/null
+++ b/docs/content/install.rst
@@ -0,0 +1,48 @@
+:title: Installation
+:date: 2022-09-22
+
+============
+Installation
+============
+
+From PyPI
+=========
+
+.. code-block:: shell
+
+ pip install reSW
+
+From tarball
+============
+
+1. `Download`_ tarball (`alterntive link `_)
+ with prebuilt Python package.
+2. Install via pip:
+
+.. code-block:: shell
+
+ pip install ./reSW-0.1.2.tar.gz
+
+From Source
+============
+
+1. `Download`_ source or clone Git repo:
+
+.. code-block:: shell
+
+ git clone https://git.nxhs.cloud/ge/rSW.git && cd rSW
+
+2. Install build deps:
+
+.. code-block:: shell
+
+ pip install --update build
+
+3. Build and install Python package:
+
+.. code-block:: shell
+
+ make
+ make install
+
+.. _Download: https://git.nxhs.cloud/ge/rSW/releases
diff --git a/docs/content/overview.rst b/docs/content/overview.rst
new file mode 100644
index 0000000..ce723f9
--- /dev/null
+++ b/docs/content/overview.rst
@@ -0,0 +1,13 @@
+:title: Overview
+:date: 2022-09-22
+
+========
+Overview
+========
+
+On this page, I will list the important features of the application that you
+may be looking for.
+
+* You can create two types of pages: blog posts and standalone pages.
+* Any page can use its own layout (template).
+* You can pass arbitrary data to templates. See `Data Sources `_
diff --git a/docs/content/quick_start.rst b/docs/content/quick_start.rst
new file mode 100644
index 0000000..d50e4af
--- /dev/null
+++ b/docs/content/quick_start.rst
@@ -0,0 +1,70 @@
+:title: Quick Start
+:date: 2022-09-22
+
+===========
+Quick Start
+===========
+
+After installation you must have these file structure::
+
+ ./
+ ├── content/
+ ├── layouts/
+ ├── Makefile
+ ├── settings.toml
+ └── static/
+
+Articles mst be placed into content/ dir and have .rst extension.
+
+Also you can place article into subdirectory as following::
+
+ ./
+ └── content/
+ └── hello_world/
+ └── index.rst
+
+You need to create page template first.
+
+Create **layouts/template.jinja2** with content:
+
+.. code-block:: jinja
+
+
+
+
+
+ {{ page.title }}
+
+
+ {{ html | safe }}
+
+
+
+Now create first page **content/index.rst**:
+
+.. code-block:: rst
+
+ :title: Hello, World!
+ :date: 1970-01-01
+
+ =============
+ Hello, World!
+ =============
+
+ Hello, there! This is my first site built with *re*\ **Structured**\ *Web*!
+
+Build your site with command:
+
+.. code-block:: shell
+
+ rsw build
+ # OR
+ make
+
+build/ directory will be created. Run local HTTP-server to view site:
+
+.. code-block:: text
+
+ make serve
+
+Local server will be started at `http://127.0.0.1:8080/ `_.
diff --git a/docs/content/rst_extensions.rst b/docs/content/rst_extensions.rst
new file mode 100644
index 0000000..9dbb67b
--- /dev/null
+++ b/docs/content/rst_extensions.rst
@@ -0,0 +1,47 @@
+:title: rST Extensions
+:date: 2022-09-29
+
+===========================
+reStructuredText Extensions
+===========================
+
+rSW includes support for a few directives and roles that are not part of
+Docutils.
+
+code-block
+==========
+
+Example:
+
+.. code-block:: text
+
+ .. code-block:: python
+
+ if __name__ == "__main__":
+ # [initialize]
+ app.start(":8000")
+ # [initialize]
+
+Result:
+
+.. code-block:: python
+
+ if __name__ == "__main__":
+ # [initialize]
+ app.start(":8000")
+ # [initialize]
+
+TODO
+====
+
+In plan:
+
+* Fully featured ``code-block`` (as in `Sphinx`_)
+* Deleted text (``)
+* Inserted text (``)
+* Keystrokes mark (``:kbd:``)
+* Spoilers (``, ``)
+* Table of Contents (``toctree``)
+* Abbreviations (``:abbr:``)
+
+.. _Sphinx: https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-code-block
diff --git a/docs/content/variables.rst b/docs/content/variables.rst
new file mode 100644
index 0000000..92e38c3
--- /dev/null
+++ b/docs/content/variables.rst
@@ -0,0 +1,130 @@
+:title: Variables
+:date: 2022-09-22
+
+=========
+Variables
+=========
+
+The following variables are passed to the template. Еach variable corresponds
+to a data source, which is described in the previous article.
+
+``page``: dict
+ Dictonary with article attributes. Data structure example:
+
+ .. code-block:: python
+
+ page = {
+ 'title': 'Variables',
+ 'date': '2022-09-22',
+ }
+
+ Note that the ``type`` and ``template`` keys are missing. These keys are
+ added implicitly. The ``page`` dict will always contain only the data
+ specified directly in the article.
+
+ Here ``type`` and ``template`` fallbacks to defaults:
+
+ .. code-block:: text
+
+ 'template': `template.jinja2`
+ 'type': 'page',
+
+ Usage example:
+
+ .. code-block:: jinja
+
+
{{ page.title }}
+
+``site``: dict
+ Dict of values from ``site`` section from **settings.toml**. The structure
+ and data types can be arbitrary.
+
+ This data can be used to add custom elements common to the entire site.
+ Below is an example of adding a list of links.
+
+ .. code-block:: toml
+
+ [site]
+ title = 'My awesome site'
+ description = 'Awesome site about awesome things'
+
+ [[site.links]]
+ title = 'GitHub'
+ url = 'https://github.com/username'
+
+ [[site.links]]
+ title = 'Twitter'
+ url = 'https://twitter.com/username'
+
+ This data is serialized into a dictionary with the following structure:
+
+ .. code-block:: python
+
+ site = {
+ 'title': 'My awesome site',
+ 'description': 'Awesome site about awesome things',
+ 'links': [
+ {
+ 'title': 'GitHub',
+ 'url': 'https://github.com/username',
+ },
+ {
+ 'title': 'Twitter',
+ 'url': 'https://twitter.com/username',
+ }
+ ]
+ }
+
+ In template:
+
+ .. code-block:: jinja
+
+ {% for link in site.links %}
+ {{ link.title }}
+ {% endfor %}
+
+``aggr``: dict
+ This dictonary contains list of posts and list of pages. The elements of
+ each list consist of dictionaries with strings.
+
+ Structure of the ``aggr`` dictonary:
+
+ .. code-block:: python
+
+ aggr = {
+ 'posts': [
+ {
+ 'title': 'Hello, World!',
+ 'date': '1970-01-01',
+ 'type': 'post'
+ },
+ {
+ 'title': 'reStructuredText Example',
+ 'date': '1970-01-01',
+ 'type': 'post'
+ }
+ ],
+ 'pages': [
+ {
+ 'title': 'Variables',
+ 'date': '2022-09-22'
+ }
+ ]
+ }
+
+ These lists are applicable, for example, to display a list of posts on the
+ blog's main page.
+
+``pygments_theme``: str
+ A string containing the name of the Pygments theme. In **settings.toml**:
+
+ .. code-block:: toml
+
+ [pygments]
+ theme = 'rrt'
+
+ The default theme is ``default``. An example of usage in a template:
+
+ .. code-block:: jinja
+
+
diff --git a/docs/layouts/template.jinja2 b/docs/layouts/template.jinja2
new file mode 100644
index 0000000..651a130
--- /dev/null
+++ b/docs/layouts/template.jinja2
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+ {{ page.title }} | {{ site.title }}
+
+
+
+
+ {% for item in site.sidebar %}
+ {% if item.title == page.title %}
+ {% set current = site.sidebar.index(item) %}
+ {% set last = site.sidebar.index(site.sidebar[-1]) %}
+ {% if current == 0 %}
+