diff options
Diffstat (limited to 'doc/index.rst')
-rw-r--r-- | doc/index.rst | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/doc/index.rst b/doc/index.rst new file mode 100644 index 0000000..9eaecfc --- /dev/null +++ b/doc/index.rst @@ -0,0 +1,84 @@ +.. Wikimini documentation master file, created by + sphinx-quickstart on Tue Aug 17 00:07:39 2021. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to Wikimini's documentation! +==================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + document + templates + formats + +Wikimini is a library that takes Wikimedia Markup and renders it into a text +format, such as `Gemtext +<https://gemini.circumlunar.space/docs/gemtext.gmi>`__:: + + from wikimini import Wikimini + from wikimini.formats.gemtext import Gemtext + import sys + + # The English Wikipedia is the default source. + wiki = Wikimini() + _, markup = wiki.retrieve("Coffee") + document = wiki.convert_to_document(markup) + Gemtext(sys.stdout).render(document) + +The reason why Wikimini is "better" than simply stripping all markup (such as +:meth:`mwparserfromhell.wikicode.Wikicode.strip_code` does) is that you can +keep a lot more information: Some interesting bits are implemented as templates +in Wikipedia (markup like ``{{lang|ar|قَهْوَة}}``), and leaving them out either +means missing out on the provided information, or having nonsensical +punctuation in your output. + +The Wikimini pipeline is made to work in three steps: + +#. We start with the parsed :class:`~mwparserfromhell.wikicode.Wikicode`, which + is a parsed representation of Wikipedia's markup language +#. Then convert the :class:`~mwparserfromhell.wikicode.Wikicode` to our + internal representation, the :class:`~wikimini.document.Document`. This step + already executes the templates and provides a stripped-down markup that only + keeps the essential meta information (like heading). +#. Lastly, we convert our :class:`~wikimini.document.Document` to our desired + format with the help of a :class:`~wikimini.formats.Format`. + +Extensibility +------------- + +Wikimini is extensible in multiple ways: + +The easiest extension is to make Wikimini work for different Mediawiki +instances. This can be done by passing the correct API URL to the constructor +of :class:`~wikimini.Wikimini`. + +You can also extend Wikimini by teaching it about more templates, for that, see +:doc:`templates`. + +Additionally, you can implement other output formats, see :doc:`formats` for +that. + +Reference +--------- + +Most of the interaction with Wikimini is done through the +:class:`wikimini.Wikimini` object: + +.. autoclass:: wikimini.Wikimini + :members: + +Additionally, the module defines some constants: + +.. autodata:: wikimini.API_URL + +.. autodata:: wikimini.TABLE_FORMAT + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` |