forked from dropbox/nautilus-dropbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocgen.py
28 lines (24 loc) · 1.06 KB
/
docgen.py
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
import os
import sys
import time
import datetime
# heeeheee
env = {"__name__":"__notmain__"}
exec(open("dropbox").read(), env)
commands = env["commands"]
f = open("AUTHORS", "r")
authors = '| ' + f.read().replace('\n', '\n| ')
f.close()
formatted_commands = ""
for cmd in commands:
split = commands[cmd].__doc__.split('\n', 2)
formatted_commands += split[1].replace(cmd, "`%s`" % cmd).replace("dropbox", "``dropbox``")
formatted_commands += split[2].replace('\n', '\n | ')
formatted_commands += '\n\n'
date = datetime.datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))).date()
sys.stdout.write(sys.stdin.read().replace\
('@AUTHORS@', authors).replace\
('@DATE@', date.isoformat()).replace\
('@PACKAGE_VERSION@', sys.argv[1]).replace\
('@SYNOPSIS@', '| '+'\n| '.join(commands[cmd].__doc__.split('\n', 2)[1].replace(cmd, "`%s`" % cmd).replace("dropbox", "``dropbox``") for cmd in commands)).replace\
('@COMMANDS@', formatted_commands))