Skip to main content

Publish RST documents in Wiki format.

Project description

Summary

Wikir (pronounced “wicker”) converts reStructuredText documents to various Wiki formats. Currently, Google Code Wiki Syntax is the target, but compatibility with Moin Moin Wiki Syntax and Trac Wiki Syntax is maintained when possible.

Installation

easy_install wikir

Or check out a development version from the subversion repository.

How Much reStructuredText Is Supported?

Not a whole lot! Since RST syntax is huge and Google Code Wiki Syntax is small, RST may never be fully supported. However, if you come across an unsupported RST directive please submit an issue and include the snippet of RST and how you think it should be displayed in wiki syntax.

If possible, also submit a failing test for the new syntax you’d like supported. You can see all currently tested and implemented RST syntax elements by running the following command (requires nose):

nosetests -v ./wikir/tests/test_syntax.py -a '!deferred'

Remove the -a '!deferred' to see those that still need implementing. Patches gladly accepted ;)

Using Wikir In Your Project

The publish_wiki Command

After installing wikir, all setuptools-enabled projects on the same machine will grow a new command, publish_wiki. A setuptools project is one with a setup.py file like so:

from setuptools import setup
setup(
    name='MyModule',
    version='0.999',
    # ...etc...
)

Command usage:

$ python setup.py publish_wiki --help
| Global options:
|   --verbose (-v)  run verbosely (default)
|   --quiet (-q)    run quietly (turns verbosity off)
|   --dry-run (-n)  don't actually do anything
|   --help (-h)     show detailed help message
|
| Options for 'publish_wiki' command:
|   --source (-s)  path to RST source.  if a python module, the top-most
|                  docstring will be used as the source
|
| usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
|    or: setup.py --help [cmd1 cmd2 ...]
|    or: setup.py --help-commands
|    or: setup.py cmd --help
|

Publishing RST To Wiki

Here is an example of publishing a module’s docstring written in RST format to Wiki format:

$ cd examples/basic
$ cat ./akimbo/__init__.py
| '''
| Welcome To Akimbo
| =================
|
| A Python module for akimbo'ing.
|
| This could live on `Google Code`_ if it wanted to.
|
| .. _Google Code: http://code.google.com/hosting/
|
| '''
$ python setup.py publish_wiki --source=./akimbo/__init__.py
| = Welcome To Akimbo =
|
| A Python module for akimbo'ing.
|
| This could live on [http://code.google.com/hosting/ Google Code] if it wanted to.
|

Using Custom RST Directives

Wikir provides an entry_point in case you need to register a custom RST directive. Here is an example:

$ cd examples/custom_directives
$ python setup.py -q develop
$ cat setup.py
| from setuptools import setup
| setup(
|     name = 'Foozilate',
|     entry_points = {
|         'wikir.rst_directives': [
|             'foozilate = foozilate.directives:foozilate'
|         ]
|     },
|     description = "A mysterious package that aids in foozilation")
$ cat ./README.txt
| This is the documentation for foozilate, which requires a custom directive called ``foozilate``.  All it does is wrap some tags around the input.
|
| .. foozilate::
|     this should be foozilated
$ python setup.py publish_wiki --source ./README.txt
| This is the documentation for foozilate, which requires a custom directive called `foozilate`.  All it does is wrap some tags around the input.
|
| --foozilated-- this should be foozilated --foozilated--
|
$ python setup.py -q develop --uninstall

The left side of the entry_point defined the directive name and the right side specifies the path to the directive function. This is registered with docutils before any RST is published.

The wikir command

If you don’t want to use wikir through setup.py you can use the command line script, wikir, which gets installed for you.

Command usge:

$ wikir --help
| usage: wikir [options] path/to/module.py
|        wikir [options] path/to/file.txt
|
| Publish RST documents in Wiki format
|
| 1. finds the top-most docstring of module.py, parses as RST, and prints Wiki format to STDOUT
| 2. parses file.txt (or a file with any other extension) as RST and prints Wiki format to STDOUT
|
| options:
|   -h, --help  show this help message and exit

You can publish a module’s docstring written in RST format to Wiki format like so:

$ cd examples/basic
$ cat ./akimbo/__init__.py
| '''
| Welcome To Akimbo
| =================
|
| A Python module for akimbo'ing.
|
| This could live on `Google Code`_ if it wanted to.
|
| .. _Google Code: http://code.google.com/hosting/
|
| '''
$ wikir ./akimbo/__init__.py
| = Welcome To Akimbo =
|
| A Python module for akimbo'ing.
|
| This could live on [http://code.google.com/hosting/ Google Code] if it wanted to.
|

… and you can publish any document written in RST format to Wiki format like so:

$ cd examples/basic
$ cat ./README.txt
| ========================
| Documentation for Akimbo
| ========================
|
| .. contents:: :local:
|
| What is it?
| ===========
|
| A Python module for akimbo'ing.
|
| Where does it live?
| ===================
|
| Akimbo could live on `Google Code`_ if it wanted to.
|
| .. _Google Code: http://code.google.com/hosting/
$ wikir ./README.txt
| = Documentation for Akimbo =
|
|   * What is it?
|   * Where does it live?
|
|
| = What is it? =
|
| A Python module for akimbo'ing.
|
| = Where does it live? =
|
| Akimbo could live on [http://code.google.com/hosting/ Google Code] if it wanted to.
|

Using Wikir Programatically

>>> from wikir import publish_string
>>> print publish_string('''
... My RST Document
... ===============
...
... For `Google Code`_!
...
... .. _Google Code: http://code.google.com/
... ''')
= My RST Document =
<BLANKLINE>
For [http://code.google.com/ Google Code]!
<BLANKLINE>
<BLANKLINE>
>>>

Credits

This work is based on code I found while snooping around the nose repository (Jason Pellerin), Ian Bicking’s docutils sandbox, and Matthew Gilbert’s docutils sandbox. Thanks to Kent S. Johnson for additional help and feedback.

Project Home

If you’re not there already, wikir lives on Google Code.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wikir-0.3.tar.gz (15.8 kB view details)

Uploaded Source

Built Distributions

wikir-0.3-py2.5.egg (32.4 kB view details)

Uploaded Source

wikir-0.3-py2.4.egg (32.6 kB view details)

Uploaded Source

File details

Details for the file wikir-0.3.tar.gz.

File metadata

  • Download URL: wikir-0.3.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for wikir-0.3.tar.gz
Algorithm Hash digest
SHA256 10b109ee65e4a3860ff4ff4b9d51e49e7de9777c4e83671e2c076dda1f944399
MD5 06d2f177b75915e62895f26997ab2df7
BLAKE2b-256 dd3a365c47f43fc7261ce4166585da62ae1243352c79cff0eec49e1909d205c6

See more details on using hashes here.

File details

Details for the file wikir-0.3-py2.5.egg.

File metadata

  • Download URL: wikir-0.3-py2.5.egg
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for wikir-0.3-py2.5.egg
Algorithm Hash digest
SHA256 431c469a34e2f1302b8f43e80eed60c13c8607087cb6b57bef26e4be62bfa869
MD5 874f1265e101af44c5b6b76a690313e4
BLAKE2b-256 3012a76a3a71cc0ec8eac0a9943e1256012850bd5b63457bf8de1ad906e3d187

See more details on using hashes here.

File details

Details for the file wikir-0.3-py2.4.egg.

File metadata

  • Download URL: wikir-0.3-py2.4.egg
  • Upload date:
  • Size: 32.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for wikir-0.3-py2.4.egg
Algorithm Hash digest
SHA256 d3db5e331f087016abca292d272f1c690b71cfc3d77875bfc32bd2eefc61be79
MD5 762519e2c4f6d0428ff0b24d09e878f3
BLAKE2b-256 b4f75c650a3b00357679b10102ce60f40a2e081034d386fe0396798e625ca392

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page