evennia/docs/README.md

497 lines
15 KiB
Markdown
Raw Normal View History

2020-06-14 20:19:31 +02:00
# Evennia docs
2020-04-05 00:02:02 +02:00
Documentation for the Evennia MUD creation system.
2020-04-10 11:19:39 +02:00
> WARNING: This system is still WIP and many things are bound to change!
2020-04-10 11:16:25 +02:00
> Contributing is still primarily to be done in the wiki.
2020-04-10 11:16:25 +02:00
The live documentation is (will in the future be) available at `https://evennia.github.io/evennia/`.
# Editing the docs
The documentation source files are `*.md` (Markdown) files found in `evennia/docs/source/`.
2020-06-14 20:19:31 +02:00
Markdown files are simple text files that can be edited with a normal text editor. They primaroly use
the [Markdown][commonmark] syntax. See [the syntax section below](#Editing-syntax) for more help.
Don't edit the files in `source/api/`. These are auto-generated and your changes
will be lost.
2020-04-10 11:16:25 +02:00
## Contributing
2020-04-10 11:01:35 +02:00
Contributing to the docs is is like [contributing to the rest of Evennia][contributing]:
2020-04-10 11:37:32 +02:00
Check out the branch of Evennia you want to edit the documentation for. Create your
2020-06-14 20:19:31 +02:00
own work-branch, make your changes to files in `evennia/docs/source/` and make a PR for it!
2020-04-05 00:02:02 +02:00
2020-06-14 20:19:31 +02:00
# Building the docs locally
2020-04-05 13:00:01 +02:00
The sources in `evennia/docs/source/` are built into a pretty documentation using
2020-04-10 11:01:35 +02:00
the [Sphinx][sphinx] static generator system. To do so locally you need to either
2020-06-14 20:19:31 +02:00
use a system with `make` (Linux/Unix/Mac or [Windows-WSL][Windows-WSL]). Lacking that, you could
in principle also run the sphinx build-commands manually - read the `evennia/docs/Makefile` to see
which commands are run by `make`.
2020-04-10 11:01:35 +02:00
You don't necessarily _have_ to build the docs locally to contribute. But
building them allows you to check for yourself that syntax is correct and that
your change comes out looking as you expected.
2020-04-05 13:00:01 +02:00
2020-04-10 11:01:35 +02:00
## Building only the main documentation
If you only want to build the main documentation pages (not the API autodocs),
you don't need to install Evennia itself, only the documentation resources.
All is done in your terminal/console.
2020-04-10 11:16:25 +02:00
- (Optional, but recommended): Activate a virtualenv with Python 3.7.
- `cd` to into the `evennia/docs` folder (where this README is).
- Install the documentation-build requirements:
2020-04-10 11:16:25 +02:00
2020-04-10 11:19:39 +02:00
```
2020-04-10 11:16:25 +02:00
make install
or
2020-04-10 11:16:25 +02:00
pip install -r requirements.txt
2020-04-10 11:19:39 +02:00
```
2020-04-10 11:16:25 +02:00
- Next, build the html-based documentation.
2020-04-10 11:16:25 +02:00
2020-04-10 11:24:05 +02:00
```
make quick
2020-04-10 11:24:05 +02:00
```
2020-04-10 11:16:25 +02:00
- The html-based documentation will appear in the new
2020-04-10 11:16:25 +02:00
folder `evennia/docs/build/html/`. Note any errors from files you have edited.
- Use a web browser to open `evennia/docs/build/html/index.html` and view the docs.
Note that you will get errors if clicking a link to the auto-docs, because you didn't build them!
2020-04-10 11:01:35 +02:00
## Building the main documentation and API docs
The full documentation includes both the doc pages and the API documentation
generated from the Evennia source. For this you must install Evennia and
initialize a new game with a default database (you don't need to have it
running)
- Follow the normal [Evennia Getting-Started instructions][getting-started]
to install Evennia. Use a virtualenv.
2020-04-10 11:16:25 +02:00
- Make sure you `cd` to the folder _containing_ your `evennia/` repo (so two levels up from `docs/`).
- Create a new game folder called `gamedir` at the same level as your `evennia`
repo with
2020-04-10 11:16:25 +02:00
2020-04-10 11:19:39 +02:00
```
2020-04-10 11:16:25 +02:00
evennia --init gamedir
2020-04-10 11:19:39 +02:00
```
2020-04-10 11:16:25 +02:00
- Then `cd` into it and create a new, empty database. You don't need to start the game
or do any further changes.
2020-04-10 11:19:39 +02:00
```
2020-04-10 11:16:25 +02:00
evennia migrate
2020-04-10 11:19:39 +02:00
```
2020-04-10 11:16:25 +02:00
- This is how the structure should look at this point:
2020-04-05 13:00:01 +02:00
2020-04-10 11:19:39 +02:00
```
(top)
|
----- evennia/ (the top-level folder, containing docs/)
|
----- gamedir/
```
2020-04-05 13:00:01 +02:00
- Make sure you are still in your virtualenv, then go to `evennia/docs/` and
2020-04-10 11:16:25 +02:00
install the doc-building requirements:
2020-04-10 11:19:39 +02:00
```
make install
or
2020-04-10 11:16:25 +02:00
pip install -r requirements.txt
2020-04-10 11:19:39 +02:00
```
2020-04-10 11:16:25 +02:00
- Finally, build the full documentation, including the auto-docs:
2020-04-10 11:19:39 +02:00
```
2020-04-10 11:16:25 +02:00
make local
2020-04-10 11:19:39 +02:00
```
2020-04-10 11:16:25 +02:00
- The rendered files will appear in a new folder `evennia/docs/build/html`.
2020-04-10 11:01:35 +02:00
Note any errors from files you have edited.
- Point your web browser to `evennia/docs/build/html/index.html` to view the full docs.
2020-04-05 15:02:38 +02:00
2020-04-10 11:37:32 +02:00
### Building with another gamedir
If you for some reason want to use another location of your `gamedir/`, or want it
2020-04-10 11:37:32 +02:00
named something else (maybe you already use the name 'gamedir' for your development ...),
you can do so by setting the `EVGAMEDIR` environment variable to the absolute path
of your alternative game dir. For example:
2020-04-10 11:37:32 +02:00
```
EVGAMEDIR=/my/path/to/mygamedir make local
```
2020-04-05 15:02:38 +02:00
## Building for release
The full Evennia documentation also tracks documentation from older Evennia
versions. This is done by pulling documentation from Evennia's old release
branches and building them all so readers can choose which one to view. Only
specific official Evennia branches will be built, so you can't use this to
build your own testing branch.
2020-04-05 15:02:38 +02:00
2020-04-10 11:01:35 +02:00
- All local changes must have been committed to git first, since the versioned
docs are built by looking at the git tree.
- To build for local checking, run (`mv` stands for "multi-version"):
2020-04-05 15:02:38 +02:00
2020-04-10 11:19:39 +02:00
```
2020-04-05 15:02:38 +02:00
make mv-local
2020-04-10 11:19:39 +02:00
```
2020-04-05 15:02:38 +02:00
- The different versions will be found under `evennia/docs/build/versions/`.
- If you have git-push access to the Evennia `gh-pages` branch on `github`, you
2020-04-10 11:24:05 +02:00
can now deploy.
2020-04-05 15:02:38 +02:00
2020-04-10 11:19:39 +02:00
```
2020-04-05 15:02:38 +02:00
make deploy
2020-04-10 11:19:39 +02:00
```
2020-04-05 15:02:38 +02:00
- If you know what you are doing you can also do build + deploy in one step:
2020-04-05 15:02:38 +02:00
2020-04-10 11:19:39 +02:00
```
2020-04-05 15:02:38 +02:00
make release
2020-04-10 11:19:39 +02:00
```
2020-04-05 15:02:38 +02:00
2020-04-10 11:37:32 +02:00
- After deployment finishes, the updated live documentation will be
2020-04-10 11:24:05 +02:00
available at `https://evennia.github.io/evennia/`.
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
# Editing syntax
The format is [Markdown][commonmark-help] (Commonmark). While markdown supports a few alternative
forms for some of these, we try to stick to the below forms for consistency.
## Italic/Bold
We generally use underscores for italics and double-asterisks for bold:
- `_Italic text_`
- `**Bold Text**`
## Headings
We use `#` to indicate sections/headings. The more `#` the more of a sub-heading it is (will get smaller
and smaller font).
- `# Heading`
- `## SubHeading`
- `## SubSubHeading`
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
> Don't reuse the same heading/subheading name over and over in the same document. While Markdown does not prevent
it, it makes it impossible to link to those duplicates properly (see next section).
2020-04-10 11:24:05 +02:00
2020-06-14 20:19:31 +02:00
## Lists
2020-06-14 20:19:31 +02:00
One can create both bullet-point lists and numbered lists:
2020-06-14 20:19:31 +02:00
```markdown
- first bulletpoint
- second bulletpoint
- third bulletpoint
```
2020-06-14 20:19:31 +02:00
```markdown
1. Numbered point one
2. Numbered point two
3. Numbered point three
```
## Notes
2020-06-14 20:19:31 +02:00
A note can be used to enphasise important things. It's added by starting one or more lines with `>`.
```
2020-06-14 20:19:31 +02:00
> Note: This is an important
> thing to remember.
```
## Links
- `[linktext](url_or_ref)` - gives a clickable link `linktext`.
2020-06-14 20:19:31 +02:00
The `url_or_ref` can either be a full `http://...` url or an internal _reference_. For example, use
`[my document](My-Document)` to link to the document `evennia/docs/source/My-Document.md`. Avoid using
full `http://` linking unless really referring to an external resource.
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
- `[linktext](ref#heading-name)`
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
You can point to sub-sections (headings) in a document by using a single `#` and the name of the
heading, replacing spaces with dashes. So to refer to a heading `## Cool Stuff` inside `My-Document`
would be a link `[cool stuff](My-Document#Cool-Stuff)`.
- `[linktext][linkref]` - refer to a reference defined later in the document.
Urls can get long and if you are using the same url in many places it can get a little cluttered. So you can also put
the url as a 'footnote' at the end of your document
and refer to it by putting your reference within square brackets `[ ]`. Here's an example:
2020-04-05 15:02:38 +02:00
```
2020-06-14 20:19:31 +02:00
This is a [clickable link][mylink]. This is [another link][1].
...
[mylink]: http://...
[1]: My-Document
2020-04-05 15:02:38 +02:00
```
2020-04-10 11:01:35 +02:00
2020-06-14 20:19:31 +02:00
### Special references
The Evennia documentation supports some special reference shortcuts in links:
#### Github online repository
- `github:` - a shortcut for the full path to the Evennia repository on github. This will refer to
the `master` branch by default:
[link to objects.py](github:evennia/objects/objects.py)
This will remap to https://github.com/evennia/evennia/blob/master/evennia/objects/objects.py.
- To refer to the `develop` branch, start the url with `develop/`:
[link to objects.py](github:develop/evennia/objects/objects.py)
#### API
- `api:` - references a path in the api documentation. This is specified as a Python-path:
[link to api for objects.py](api:evennia.objects)
This will create a link to the auto-generated `evennia/source/api/evennia.objects.rst` document.
Since api-docs are generated alongside the documentation, this will always be the api docs for the
current version/branch of the docs.
#### Bug reports/feature request
- `issue`, `bug-report`, `feature-request` - links to the same github issue select page.
If you find a problem, make a [bug report](issue)!
This will generate a link to https://github.com/evennia/evennia/issues/new/choose.
> For some reason these particular shortcuts gives a warning during documentation compilation. This
> can be ignored.
## Verbatim text
It's common to want to mark something to be displayed verbatim - just as written - without any
Markdown parsing. In running text, this is done using backticks (\`), like \`verbatim text\` becomes `verbatim text`.
If you want to put the verbatim text on its own line, you can do so easily by simply indenting
it 4 spaces (add empty lines on each side for readability too):
2020-04-05 15:02:38 +02:00
```
2020-06-14 20:19:31 +02:00
This is normal text
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
This is verbatim text
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
This is normal text
2020-04-05 15:02:38 +02:00
```
2020-06-14 20:19:31 +02:00
Another way is to use triple-backticks:
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
````
2020-04-05 15:02:38 +02:00
```
2020-06-14 20:19:31 +02:00
Everything within these backticks will be verbatim.
2020-04-05 15:02:38 +02:00
```
2020-06-14 20:19:31 +02:00
````
## Code blocks
A special case is code examples - we want them to get code-highlighting for readability. This is done by using
the triple-backticks and specify which language we use:
````
```python
def a_python_func(x):
return x * x
```
````
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
## ReST blocks
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
Markdown is easy to read and use. But while it does most of what we need, there are some things it's
not quite as expressive as it needs to be. For this we need to fall back to the [ReST][ReST] markup
language which the documentation system uses under the hood. This is done by specifying `eval_rst` as
the name of the `language` of a literal block:
````
```eval_rst
This will be evaluated as ReST.
```
````
There is also a short-hand form for starting a [ReST directive][ReST-directives] without need for `eval_rst`:
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
````
```directive:: possible-option
Content that *must* be indented for it to be included in the directive.
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
New lines are ignored except if separated by an empty line.
2020-04-05 15:02:38 +02:00
```
2020-06-14 20:19:31 +02:00
````
2020-06-14 20:19:31 +02:00
See below for examples of this.
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
#### Important
This will display a one-line note that will pop even more than a normal `> note`.
````
```important::
This is important because it is!
2020-04-05 15:02:38 +02:00
```
2020-06-14 20:19:31 +02:00
````
#### Warning
A warning block is used to draw attention to particularly dangerous things, or features easy to
mess up.
````
```warning::
Be careful about this ...
````
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
#### Version changes and deprecations
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
These will show up as one-line warnings that suggest an added, changed or deprecated
feature beginning with particular version.
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
````
```versionadded:: 1.0
```
````
````
```versionchanged:: 1.0
How the feature changed with this version.
```
````
````
```deprecated:: 1.0
```
````
2020-04-05 15:02:38 +02:00
2020-06-14 20:19:31 +02:00
#### Sidebar
This will display an informative sidebar that floats to the side of regular content. This is useful
for example to remind the reader of some concept relevant to the text.
````
```sidebar:: Things to remember
- There can be bullet lists
- in here.
Headers with indented blocks:
like this
Will end up as full sub-headings:
in the sidebar.
```
````
> Remember that for ReST-directives, the content within the triple-backticks _must_ be indented to
>some degree or the content will just appear outside of the directive as regular text.
#### Tables
A table is specified using [ReST table syntax][ReST-tables]:
````
```eval_rst
===== ===== =======
A B A and B
===== ===== =======
False False False
True False False
False True False
True True True
===== ===== =======
```
````
or the more flexible but verbose
````
```eval_rst
+------------------------+------------+----------+----------+
| Header row, column 3 | Header 2 | Header 3 | Header 4 |
| (header rows optional) | | | |
+========================+============+==========+==========+
| body row 1, column 1 | column 2 | column 3 | column 4 |
+------------------------+------------+----------+----------+
| body row 2 | ... | ... | |
+------------------------+------------+----------+----------+
```
````
#### A more flexible code block
The regular Markdown codeblock is usually enough but for more direct control over the style, one
can also specify the code block explicitly in `ReST`.
for more flexibility. It also provides a link to the code block, identified by its name.
````
```code-block:: python
:linenos:
:emphasize-lines: 6-7,12
:caption: An example code block
:name: A full code block example
from evennia import Command
class CmdEcho(Command):
"""
Usage: echo <arg>
"""
key = "echo"
def func(self):
self.caller.msg(self.args.strip())
```
````
Here, `:linenos:` turns on line-numbers and `:emphasize-lines:` allows for emphasizing certain lines
in a different color. The `:caption:` shows an instructive text and `:name:` is used to reference this
block through the link that will appear (so it should be unique for a give document).
> The default markdown syntax will actually generate a code-block ReST instruction like this
> automatically for us behind the scenes. The automatic generation can't know things like emphasize-lines
> or caption since that's not a part of the Markdown specification.
2020-04-05 15:02:38 +02:00
# Technical
Evennia leverages [Sphinx][sphinx] with the [recommonmark][recommonmark] extension, which allows us to write our
docs in light-weight Markdown (more specifically [CommonMark][commonmark], like on github) rather than ReST.
The recommonmark extension however also allows us to use ReST selectively in the places were it is more
expressive than the simpler (but much easier) Markdown.
For [autodoc-generation][sphinx-autodoc] generation, we use the sphinx-[napoleon][sphinx-napoleon] extension
to understand our friendly Google-style docstrings used in classes and functions etc.
2020-06-14 20:19:31 +02:00
2020-04-05 15:02:38 +02:00
[sphinx]: https://www.sphinx-doc.org/en/master/
[recommonmark]: https://recommonmark.readthedocs.io/en/latest/index.html
[commonmark]: https://spec.commonmark.org/current/
2020-06-14 20:19:31 +02:00
[commonmark-help]: https://commonmark.org/help/
2020-04-05 15:02:38 +02:00
[sphinx-autodoc]: http://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#module-sphinx.ext.autodoc
[sphinx-napoleon]: http://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html
[getting-started]: https://github.com/evennia/evennia/wiki/Getting-Started
2020-04-10 11:37:32 +02:00
[contributing]: https://github.com/evennia/evennia/wiki/Contributing
2020-06-14 20:19:31 +02:00
[ReST]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html
[ReST-tables]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#tables
[ReST-directives]: https://www.sphinx-doc.org/en/master/usage/restruturedtext/directives.html
[Windows-WSL]: https://docs.microsoft.com/en-us/windows/wsl/install-win10