The PyNSource python code scanner and UML modelling tool can generate UML text diagrams, which you can paste into your source code for documentation purposes.
You can use an Text Art editor to arrange your text UML pictures into properly laid out diagrams and embed them in your doc strings inside your source code. Here is an example of a UML ascii doc string:
"""
Provides the API for talking to the game, from the AI's point of view.
+---------------------------+
+------------------------------------+ |RoleServicesObject |
|AI | |...........................|
|..................................... * |role |
|roleServiceObjects '''''''''''''|gameservices |----- ...|
+-----+ |gameServices |_____ |_rolemanager | |
|game `-. |....................................| | |_etc1 | |
+-----+ `-.|API_RunABit | | |...........................| |
|API_GetOrdersForRole | | |API_GetCurrentStoryline | |
|API_CreateRoleServicesObjectForRole | | |API_GetCurrentRoleName | |
+------------------------------------+ | |API_GetRoleSubordinates | |
| +---------------------------+ |
| |
| |
| 1 +-------------------------------+ / |
.---+GameServices |_.......'
+-------------------------------| -.
|_scenario |
|_game |
................................|
|API_GetAstarTravelTimeBlahBlah |
|API_GetOobtreeInfoOnOobId |
|API_GetOobtreeInfoOnMe |
+-------------------------------+
"""
Example
The following python code:
class ParseMeTest:
def __init__(self):
self.a = 10 # class attribute
self.b = Blah() # class attribute COMPOSITE
self.a.c = 20 # skip
self.__class__.d = 30 # static class attribute
self.e.append(10) # class attribute (list/vector)
self.f.append(Blah()) # class attribute (list/vector) COMPOSITE
def IsInBattle(self):
if not self.tileinfo:
return 0
return self.tileinfo.battletriggered
def DoA(self):
pass
class ParseMeTest2(ParseMeTest):
def DoB(self):
self._secretinfo = 2
is converted to two ascii representations of UML classes:
--------------------
ParseMeTest --------|> []
--------------------
a
b <@>----> ['Blah']
d static
e 1..*
f <@>----> ['Blah'] 1..*
--------------------
__init__
IsInBattle
DoA
--------------------
--------------------
ParseMeTest2 --------|> ['ParseMeTest']
--------------------
_secretinfo
--------------------
DoB
--------------------
--------------------
Blah --------|> []
--------------------
--------------------
__init__
--------------------
using the command
e.g.
\python22\python.exe \Python22\Lib\site-packages\pynsource\pynsource.py pythoninputfile.py
Symbol Meanings
| composition |
a <@>----> [A ] |
attribute b composite relationship to A (i.e. the class in which a lives creates an instance of A and stores that in instance variable a) e.g. self.a = A() |
| inheritance |
B --------|> [A ] |
class B inherits from class A |
