File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ Language dictionaries markdown table generation.
3
+ """
4
+
5
+ from glob import glob
6
+ import os
7
+ import yaml
8
+
9
+ def get_table_rows ():
10
+ "Get markdown table for docs."
11
+ thisdir = os .path .dirname (__file__ )
12
+ langglob = os .path .join (thisdir , "**" , "definition.yaml" )
13
+ output = []
14
+ for filename in glob (langglob ):
15
+ with open (filename , "r" , encoding = "utf-8" ) as f :
16
+ y = yaml .safe_load (f )
17
+ langname = y ["name" ]
18
+ for d in y ["dictionaries" ]:
19
+ data = [
20
+ langname ,
21
+ d ["for" ],
22
+ d ["type" ],
23
+ f"`{ d ['url' ]} `"
24
+ ]
25
+ output .append ("|" + "|" .join (data ) + "|" )
26
+ output .sort ()
27
+ return output
28
+
29
+
30
+ def generate_table ():
31
+ "Gen table"
32
+ print ("|Language|For|Type|URL|" )
33
+ print ("|---|---|---|---|" )
34
+ rows = get_table_rows ()
35
+ print ("\n " .join (rows ))
36
+
37
+
38
+ if __name__ == "__main__" :
39
+ generate_table ()
You can’t perform that action at this time.
0 commit comments