aboutsummaryrefslogtreecommitdiffstats
path: root/generate_docs.py
blob: d21d85583e55039eeb154a32164451be20b9efac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/python2
# -*- coding: utf-8 -*-

from __future__ import print_function, unicode_literals

from textwrap import dedent
import wee_slack

cmds = wee_slack.EventRouter().cmds
options = wee_slack.PluginConfig.default_settings

with open('docs/Commands.md', 'w') as file_cmds:
    file_cmds.write(dedent("""
        # Commands

        These are the commands made available by this script. In In addition to
        these commands, most normal IRC commands, like `/join`, `/part`,
        `/query`, `/msg`, `/me`, `/topic`, `/away` and `/whois` work normally.
        See [WeeChat's
        documentation](https://weechat.org/files/doc/stable/weechat_user.en.html)
        or `/help <cmd>` if you are unfamiliar with these.

        ## Available commands:

        """).lstrip())

    for name, cmd in sorted(cmds.items()):
        doc = dedent(cmd.__doc__ or '').strip()
        command, helptext = doc.split('\n', 1)
        file_cmds.write(dedent("""
            ### {}

            ```
            {}
            ```

            {}

            """).lstrip().format(name, command, helptext))

with open('docs/Options.md', 'w') as file_options:
    file_options.write(dedent("""
        # Options

        You can set these options by using:

        ```
        /set plugins.var.python.slack.option_name value
        ```

        You can also see all the options and set them them interactively by running `/fset slack`.

        Note that the default value will be shown as an empty string in weechat.
        The actual default values are listed below.

        Most options require that you reload the script with `/python reload
        slack` after changing it to take effect.

        ## Available options:

        """).lstrip())

    for name, option in sorted(options.items()):
        file_options.write(dedent("""
            ### {}

            **Default:** `{}`

            **Description:** {}

            """).lstrip().format(name, option.default, option.desc))