/
documentator.go
62 lines (37 loc) · 1.11 KB
/
documentator.go
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
package documentordriver
/* For documenting purposes, this driver will generate html/css code for both the minimal go program and the RIB output */
import (
"sync"
"log"
. "github.com/mae-global/rigo2/ri"
. "github.com/mae-global/rigo2/ri/core"
. "github.com/mae-global/rigo2/drivers"
)
type documentorDriver struct {
sync.RWMutex
last string
progress *ProtectedInteger
}
func (d *documentorDriver) Flush(marker RtString, synchronous RtBoolean, flushmode RtToken) {
}
func (d *documentorDriver) GetProgress() RtInt {
d.progress.RLock()
defer d.progress.RUnlock()
return RtInt(d.progress.Value)
}
func (d *documentorDriver) Handle(name RtString, args []RtPointer, tokens []RtPointer, values []RtPointer) *RtError {
d.last = RIBStream(name, args, tokens, values)
return nil
}
func (d *documentorDriver) Close() *RtError {
return nil
}
func (d *documentorDriver) GetLastRIB() string {
return d.last
}
func BuildDriver(logger *log.Logger, options []RtPointer, args ...string) (Driver, error) {
d := &documentorDriver{}
d.progress = new(ProtectedInteger)
d.progress.Value = 100
return d, nil
}