-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgen_docs.py
31 lines (24 loc) · 1.15 KB
/
gen_docs.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
29
30
31
"""
This file is part of BaNaNaS2, an Add-on Content Management System for OpenTTD.
Copyright (C) 2018, 2020 The OpenTTD team
BaNaNaS2 is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation, version 2.
BaNaNaS2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details. You should have received a copy of the
GNU General Public License along with BaNaNaS2. If not, see <http://www.gnu.org/licenses/>.
"""
from bananas2.data.tables import Base
print("@startuml")
for t in Base.metadata.tables.values():
print("class {} {{".format(t.name))
for col in t.columns:
non_null = ""
if col.nullable:
non_null = " [0..1]"
print(" {} : {}{}".format(col.name, col.type.__str__().partition("(")[0], non_null))
print("}")
refs = set(ref.column.table.name for ref in t.foreign_keys)
for ref in refs:
print("{} --> {}".format(t.name, ref))
print("@enduml")