mirror of
https://github.com/Luzifer/discord-community.git
synced 2024-12-20 10:21:22 +00:00
Add docs generator
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
a7ac29f637
commit
1e3891bb67
5 changed files with 110 additions and 1 deletions
16
Makefile
Normal file
16
Makefile
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
default:
|
||||||
|
|
||||||
|
gendoc: .venv
|
||||||
|
.venv/bin/python3 ci/gendoc.py $(shell grep -l '@module ' *.go) >wiki/Home.md
|
||||||
|
|
||||||
|
.venv:
|
||||||
|
python -m venv .venv
|
||||||
|
.venv/bin/pip install -r ci/requirements.txt
|
||||||
|
|
||||||
|
# --- Wiki Updates
|
||||||
|
|
||||||
|
pull_wiki:
|
||||||
|
git subtree pull --prefix=wiki https://github.com/Luzifer/discord-community.wiki.git master --squash
|
||||||
|
|
||||||
|
push_wiki:
|
||||||
|
git subtree push --prefix=wiki https://github.com/Luzifer/discord-community.wiki.git master
|
50
ci/gendoc.py
Normal file
50
ci/gendoc.py
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import jinja2
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def main(args):
|
||||||
|
modules = []
|
||||||
|
|
||||||
|
for filename in args:
|
||||||
|
with open(filename, 'r') as codefile:
|
||||||
|
mod = {
|
||||||
|
'attributes': [],
|
||||||
|
}
|
||||||
|
|
||||||
|
for line in codefile:
|
||||||
|
match = re.search(r'@module (.*)', line)
|
||||||
|
if match is not None:
|
||||||
|
mod['type'] = match[1]
|
||||||
|
|
||||||
|
match = re.search(r'@module_desc (.*)', line)
|
||||||
|
if match is not None:
|
||||||
|
mod['description'] = match[1]
|
||||||
|
|
||||||
|
match = re.search(
|
||||||
|
r'@attr ([^\s]+) ([^\s]+) ([^\s]+) "([^"]*)" (.*)', line)
|
||||||
|
if match is not None:
|
||||||
|
mod['attributes'].append({
|
||||||
|
'name': match[1],
|
||||||
|
'required': match[2],
|
||||||
|
'type': match[3],
|
||||||
|
'default': match[4],
|
||||||
|
'description': match[5],
|
||||||
|
})
|
||||||
|
|
||||||
|
mod['attributes'] = sorted(
|
||||||
|
mod['attributes'], key=lambda a: ('0' if a['required'] == 'required' else '1') + ':' + a['name'])
|
||||||
|
|
||||||
|
modules.append(mod)
|
||||||
|
|
||||||
|
with open('docs/Home.md.tpl', 'r') as f:
|
||||||
|
tpl = jinja2.Template(f.read())
|
||||||
|
print(tpl.render(modules=modules))
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main(sys.argv[1:]))
|
1
ci/requirements.txt
Normal file
1
ci/requirements.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
jinja2
|
27
wiki/Home.md
27
wiki/Home.md
|
@ -1 +1,26 @@
|
||||||
Welcome to the discord-community wiki!
|
# Discord-Community
|
||||||
|
|
||||||
|
## Modules
|
||||||
|
|
||||||
|
### schedule
|
||||||
|
|
||||||
|
Posts stream schedule derived from Twitch schedule as embed in Discord channel
|
||||||
|
|
||||||
|
| Attribute | Required | Type | Default Value | Description |
|
||||||
|
| --------- | -------- | ---- | ------------- | ----------- |
|
||||||
|
| `discord_channel_id` | ✅ | string | | ID of the Discord channel to post the message to |
|
||||||
|
| `embed_title` | ✅ | string | | Title of the embed (used to find the managed post, must be unique for that channel) |
|
||||||
|
| `twitch_channel_id` | ✅ | string | | ID (not name) of the channel to fetch the schedule from |
|
||||||
|
| `twitch_client_id` | ✅ | string | | Twitch client ID the token was issued for |
|
||||||
|
| `twitch_token` | ✅ | string | | Token for the user the `twitch_channel_id` belongs to |
|
||||||
|
| `cron` | | string | `*/10 * * * *` | When to execute the schedule transfer |
|
||||||
|
| `embed_color` | | int64 | `3066993` | Integer representation of the hex color for the embed (default is #2ECC71) |
|
||||||
|
| `embed_description` | | string | | Description for the embed block |
|
||||||
|
| `embed_thumbnail_height` | | int64 | | Height of the thumbnail |
|
||||||
|
| `embed_thumbnail_url` | | string | | Publically hosted image URL to use as thumbnail |
|
||||||
|
| `embed_thumbnail_width` | | int64 | | Width of the thumbnail |
|
||||||
|
| `schedule_entries` | | int64 | `5` | How many schedule entries to add to the embed as fields |
|
||||||
|
| `schedule_past_time` | | duration | `15m` | How long in the past should the schedule contain an entry |
|
||||||
|
|
||||||
|
|
||||||
|
<!-- vim: set ft=markdown : -->
|
||||||
|
|
17
wiki/Home.md.tpl
Normal file
17
wiki/Home.md.tpl
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# Discord-Community
|
||||||
|
|
||||||
|
## Modules
|
||||||
|
|
||||||
|
{% for module in modules -%}
|
||||||
|
### {{ module.type }}
|
||||||
|
|
||||||
|
{{ module.description }}
|
||||||
|
|
||||||
|
| Attribute | Required | Type | Default Value | Description |
|
||||||
|
| --------- | -------- | ---- | ------------- | ----------- |
|
||||||
|
{%- for attr in module.attributes %}
|
||||||
|
| `{{ attr.name }}` | {% if attr.required == 'required' %}✅{% endif %} | {{ attr.type }} | {% if attr.default != "" %}`{{ attr.default }}`{% endif %} | {{ attr.description }} |
|
||||||
|
{%- endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<!-- vim: set ft=markdown : -->
|
Loading…
Reference in a new issue