summaryrefslogtreecommitdiff
path: root/sandbox/cliechti/aafigure/README.txt
blob: 473fa0e70b45ed4ef34d61fe3e99d9ffa47adf91 (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
aafigure README
===============

Overview
--------

The idea is to parse ASCII art images, embedded in reST documents and output
an image. This would mean that simple illustrations could be embedded as
ASCII art in the reST source and still look nice when converted to e.g. HTML

Implementation
--------------

Files:

aafigure.py
    ASCII art parser. This is the main module.

aafigure_directive.py
    Implmements the ``aafigure`` Docutils directive that takes these
    ASCII art figures ang generates SVG.

aa.py
    ASCII art output backend. Intended for tests, not for the end user.

rst2html.py
    Patched version that adds the ``aafigure`` Docutils directive.
    
svg.py
    SVG output backend.


Usage
-----
::

    ./rst2html.py README.txt >README.html

This results in the ``README.html`` file and a ``.svg`` file for each
``aafigure``.

Display the resulting ``README.html`` file in a SVG capable browser. It has
been tested with Firefox 1.5.

TODO
----

- symbol detection: scan for some predefined shapes in the ASCII image
  and output them as symbol form a library
- symbol libraries for UML, flowchart, electronic schematics, ...
- more arrow heads
- the way the image is embedded is a hack (inserting an ``<embed ..>`` tag
  trough a raw node...
- search for ways to bring in color
- aafigure probably need arguments like ``font-family``, ...
- punctuation not included in strings

License
-------

BSD

Tests
-----

Simple tests
~~~~~~~~~~~~
.. aafigure::

    -->

.. aafigure::

    +---------------+
    |A box with text|
    +---------------+

.. aafigure::

        ---> | ^|   |
        <--- | || --+--
        <--> | |V   |
     __             __
    |  |__  +---+  |__|
            |box|   ..
            +---+  Xenophon

A flow chart
~~~~~~~~~~~~
.. aafigure::
    :scale: 0.6

        +---------+
        | State 1 |
        +----+----+
             |
             +<------+
             |       |
             V       |
        +----+----+  |
        | State 2 |  |
        +----+----+  |
             |       |
             V       |
        +----+----+  |
        | State 3 |  |
        +----+----+  |
             |       |
             +-------+

UML
~~~
No not realy, yet. But you get the idea.

.. aafigure::

    object 1   object 2
    ----+----  ----+----
        |          |
        |          |
        X          |
        X--------->X
        X          X
        X<---------X
        X          |
        |          |
        |          |

Electronics
~~~~~~~~~~~
It would be cool if it could display simple schematics.

.. aafigure::

           R1    
    o------XXXX----+-----o
           100k    |
                  -+- C1
                  -+- 100n
                   |
    o--------------+-----o

- Resistor should not be filled -> can be solved by symbol detection
- Capacitor not good, would prefer --||--  -> symbol detection

Timing diagrams
~~~~~~~~~~~~~~~
.. aafigure::
    :scale: 0.4

        ___     ___
    ___|   |___|   |_____________________
          ___     ___
    _____|   |___|   |___________________

Or one with descriptions:

.. aafigure::
    :scale: 0.8

                        sda_edge
         start                              stop
           |    |          |                 |
           v    v          v                 v
        ___      __________                   ___
    SDA    |    |          |                 |
           |____|          |_____..._________|
        ______      _____       _..._       _____
    SCL       |    |     |     |     |     |
              |____|     |_____|     |_____|
                                            
              ^    ^     ^     ^     ^     ^
              |    |     |     |     |     |  
              |  sh_in   |   sh_in   |   sh_in
            sh_out     sh_out      sh_out   
                                            
                        scl_edge