This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Planofile
105 lines (84 loc) · 3.19 KB
/
Planofile
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
from distutils.file_util import write_file
from plano import *
import csv
import os
import re
import sys
import sys;print(sys.version)
regexp_term = re.compile(r'^\s*\-\-(.*?) .*')
nl='\n'
@command
def generateAdoc():
"""
Generate asciidoc files
"""
logseqDir = get_current_dir()
dirName='skupper-generate'
with working_dir(dirName):
print(get_current_dir())
for path in find("./", "*.md"):
print(path)
cmd = "kramdoc --format=GFM --wrap=ventilate " + path
result = call(cmd,"","shell=true")
print(result)
@command
def updateAdoc():
"""
Update asciidoc files
"""
logseqDir = get_current_dir()
dirName='skupper-generate'
with working_dir(dirName):
print(get_current_dir())
for path in find("./", "*.adoc"):
print(path)
lines=read_lines(path)
write_file(path, '')
for line in lines:
# H1
line = replace(line,'^==','=')
line = replace(line,'== Synopsis','.Synopsis')
line = replace(line,'----','')
line = replace(line,'== Options', '.Options')
# find end material
#
line = replace(line,'.* -h, --help .*','// ')
line = replace(line,' -c, --context string The kubeconfig context to use','// ')
line = replace(line,'.*--kubeconfig.*','// ')
line = replace(line,' -n, --namespace string The Kubernetes namespace to use','// ')
# find options
if (result := re.match(r"skupper (.*)\[flags\]", line)) is not None:
line= ' skupper ' + result[1] + ' --[option]\n\n'
if (result := re.match(r" --(.*)\b(.*)?[ ]{2,}(.*)", line)) is not None:
if (optionType := re.split(r"\s", result[1])) is not None:
if len(optionType)>1:
line= optionType[0] + ':: \n' + result[3] + '\n ('+ optionType[1] +')\n'
else:
line= optionType[0] + ':: \n' + result[3] + '\n (bool)\n'
line = replace(line,'== SEE ALSO','.See also')
line = replace(line,'\[discrete\]','')
line = replace(line,'^====','// ')
append_lines(path, line)
@command
def generate():
"""
Generate terminology
"""
logseqDir = get_current_dir()
dirName='skupper-generate'
page= logseqDir +'/pages/terms.md'
write(page, '# Terms' +nl)
with working_dir(dirName):
print(get_current_dir())
for path in find("./", "*.md"):
print(path)
adoc = md_parse(path, page)
def md_parse(path, page):
append(page,nl+ '## ' +path +nl)
for line in read_lines(path):
line = line.rstrip()
if (regexp_term.search(line)):
term= regexp_term.match(line).group(1)
#print(regexp_term.match(line).group(1))
term = "* [["+term+"]]"
append(page,term+nl + line +nl)