mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-30 15:32:41 +00:00
doc: update scripts to python3
This commit is contained in:
parent
ccaf0865c0
commit
3789dc732d
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import sys, os, shutil
|
import sys, os, shutil
|
||||||
import re, yaml
|
import re, yaml
|
||||||
@ -74,9 +74,9 @@ def main(argv):
|
|||||||
yml_file = "mkdocs.yml"
|
yml_file = "mkdocs.yml"
|
||||||
|
|
||||||
with open(yml_file, 'r') as yin:
|
with open(yml_file, 'r') as yin:
|
||||||
doc = yaml.load(yin)
|
doc = yaml.load(yin, Loader=yaml.SafeLoader)
|
||||||
for page in doc["pages"]:
|
for page in doc["pages"]:
|
||||||
mk_file = page.values()[0]
|
mk_file = list(page.values())[0]
|
||||||
source_file = md_template +"/"+ mk_file
|
source_file = md_template +"/"+ mk_file
|
||||||
dest_file = md_final +"/"+ mk_file
|
dest_file = md_final +"/"+ mk_file
|
||||||
print("Processing %s -> %s" % (source_file, dest_file))
|
print("Processing %s -> %s" % (source_file, dest_file))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import sys, yaml
|
import sys, yaml
|
||||||
import os, re
|
import os, re
|
||||||
@ -60,10 +60,10 @@ def main(argv):
|
|||||||
|
|
||||||
with open(mk_file, 'w') as aout:
|
with open(mk_file, 'w') as aout:
|
||||||
with open(yml_file, 'r') as yin:
|
with open(yml_file, 'r') as yin:
|
||||||
doc = yaml.load(yin)
|
doc = yaml.load(yin, Loader=yaml.SafeLoader)
|
||||||
for page in doc["pages"]:
|
for page in doc["pages"]:
|
||||||
title = page.keys()[0]
|
title = list(page.keys())[0]
|
||||||
md_file = page.values()[0]
|
md_file = list(page.values())[0]
|
||||||
with open(docs_folder +"/"+ md_file, 'r') as mdin:
|
with open(docs_folder +"/"+ md_file, 'r') as mdin:
|
||||||
aout.write("\n\n#"+ title +"\n\n")
|
aout.write("\n\n#"+ title +"\n\n")
|
||||||
for line in mdin:
|
for line in mdin:
|
||||||
@ -80,7 +80,7 @@ def main(argv):
|
|||||||
while 1:
|
while 1:
|
||||||
line = p.readline()
|
line = p.readline()
|
||||||
if not line: break
|
if not line: break
|
||||||
print line
|
print (line)
|
||||||
|
|
||||||
|
|
||||||
# btstatck_root_file = "latex/btstack_gettingstarted.tex"
|
# btstatck_root_file = "latex/btstack_gettingstarted.tex"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os, sys, shutil, re, pickle
|
import os, sys, shutil, re, pickle
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import sys, os, shutil, re
|
import sys, os, shutil, re
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ port_item = """
|
|||||||
|
|
||||||
def get_readme_title(example_path):
|
def get_readme_title(example_path):
|
||||||
title = ''
|
title = ''
|
||||||
with open(example_path, 'rb') as fin:
|
with open(example_path, 'r') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
parts = re.match('(##\s)(.*)\n',line)
|
parts = re.match('(##\s)(.*)\n',line)
|
||||||
if parts:
|
if parts:
|
||||||
@ -34,13 +34,13 @@ def process_readmes(intro_file, port_folder, ports_file, ports_folder):
|
|||||||
images[file] = port_folder + "/" + port + "/" + file
|
images[file] = port_folder + "/" + port + "/" + file
|
||||||
|
|
||||||
with open(ports_file, 'w') as ports:
|
with open(ports_file, 'w') as ports:
|
||||||
with open(intro_file, 'rb') as fin:
|
with open(intro_file, 'r') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
ports.write(line)
|
ports.write(line)
|
||||||
fin.close()
|
fin.close()
|
||||||
|
|
||||||
for readme_dir, readme_file in sorted(matches.items()):
|
for readme_dir, readme_file in sorted(matches.items()):
|
||||||
with open(readme_file, 'rb') as fin:
|
with open(readme_file, 'r') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
# find title, add reference
|
# find title, add reference
|
||||||
title_parts = re.match('(#\s+)(.*)\n',line)
|
title_parts = re.match('(#\s+)(.*)\n',line)
|
||||||
@ -52,7 +52,7 @@ def process_readmes(intro_file, port_folder, ports_file, ports_folder):
|
|||||||
ports.write("\n\n")
|
ports.write("\n\n")
|
||||||
|
|
||||||
for readme_dir, readme_file in sorted(matches.items()):
|
for readme_dir, readme_file in sorted(matches.items()):
|
||||||
with open(readme_file, 'rb') as fin:
|
with open(readme_file, 'r') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
#increase level of indentation
|
#increase level of indentation
|
||||||
parts = re.match('#(.*)\n',line)
|
parts = re.match('#(.*)\n',line)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
import os, sys, getopt, re, pickle
|
import os, sys, getopt, re, pickle
|
||||||
|
|
||||||
class State:
|
class State:
|
||||||
@ -77,7 +77,7 @@ def writeAPI(apifile, btstackfolder, apis, mk_codeidentation):
|
|||||||
fout.write(title)
|
fout.write(title)
|
||||||
|
|
||||||
state = State.SearchStartAPI
|
state = State.SearchStartAPI
|
||||||
with open(api_filename, 'rb') as fin:
|
with open(api_filename, 'r') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
if state == State.SearchStartAPI:
|
if state == State.SearchStartAPI:
|
||||||
parts = re.match('.*API_START.*',line)
|
parts = re.match('.*API_START.*',line)
|
||||||
@ -103,7 +103,7 @@ def createIndex(btstackfolder, apis, githubfolder):
|
|||||||
api_lable = api_tuple[2]
|
api_lable = api_tuple[2]
|
||||||
|
|
||||||
linenr = 0
|
linenr = 0
|
||||||
with open(api_filename, 'rb') as fin:
|
with open(api_filename, 'r') as fin:
|
||||||
typedefFound = 0
|
typedefFound = 0
|
||||||
multiline_function_def = 0
|
multiline_function_def = 0
|
||||||
state = State.SearchStartAPI
|
state = State.SearchStartAPI
|
||||||
@ -195,11 +195,11 @@ def main(argv):
|
|||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(argv,"hiso:",["bfolder=","afile=","gfolder=","ifile="])
|
opts, args = getopt.getopt(argv,"hiso:",["bfolder=","afile=","gfolder=","ifile="])
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
print cmd
|
print (cmd)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
if opt == '-h':
|
if opt == '-h':
|
||||||
print cmd
|
print (cmd)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
elif opt in ("-b", "--bfolder"):
|
elif opt in ("-b", "--bfolder"):
|
||||||
btstackfolder = arg
|
btstackfolder = arg
|
||||||
@ -209,10 +209,10 @@ def main(argv):
|
|||||||
btstackfolder = arg
|
btstackfolder = arg
|
||||||
elif opt in ("-i", "--ifile"):
|
elif opt in ("-i", "--ifile"):
|
||||||
indexfile = arg
|
indexfile = arg
|
||||||
print 'BTstack folder is :', btstackfolder
|
print ('BTstack folder is : ' + btstackfolder)
|
||||||
print 'API file is :', apifile
|
print ('API file is : ' + apifile)
|
||||||
print 'Github path is :', githubfolder
|
print ('Github path is : ' + githubfolder)
|
||||||
print 'Index file is :', indexfile
|
print ('Index file is : ' + indexfile)
|
||||||
|
|
||||||
writeAPI(apifile, btstackfolder, apis, mk_codeidentation)
|
writeAPI(apifile, btstackfolder, apis, mk_codeidentation)
|
||||||
createIndex(btstackfolder, apis, githubfolder)
|
createIndex(btstackfolder, apis, githubfolder)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
import os, sys, getopt, re
|
import os, sys, getopt, re
|
||||||
|
|
||||||
# Defines the names of example groups. Preserves the order in which the example groups will be parsed.
|
# Defines the names of example groups. Preserves the order in which the example groups will be parsed.
|
||||||
@ -111,7 +111,7 @@ def processTextLine(line, ref_prefix):
|
|||||||
|
|
||||||
def getExampleTitle(example_path):
|
def getExampleTitle(example_path):
|
||||||
example_title = ''
|
example_title = ''
|
||||||
with open(example_path, 'rb') as fin:
|
with open(example_path, 'r') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
parts = re.match('.*(EXAMPLE_START)\((.*)\):\s*(.*)(\*/)?\n',line)
|
parts = re.match('.*(EXAMPLE_START)\((.*)\):\s*(.*)(\*/)?\n',line)
|
||||||
if parts:
|
if parts:
|
||||||
@ -151,7 +151,7 @@ def writeListings(aout, infile_name, ref_prefix):
|
|||||||
code_identation = " "
|
code_identation = " "
|
||||||
skip_code = 0
|
skip_code = 0
|
||||||
|
|
||||||
with open(infile_name, 'rb') as fin:
|
with open(infile_name, 'r') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
if state == State.SearchExampleStart:
|
if state == State.SearchExampleStart:
|
||||||
parts = re.match('.*(EXAMPLE_START)\((.*)\):\s*(.*)(\*/)?\n',line)
|
parts = re.match('.*(EXAMPLE_START)\((.*)\):\s*(.*)(\*/)?\n',line)
|
||||||
@ -256,22 +256,22 @@ def writeListings(aout, infile_name, ref_prefix):
|
|||||||
parts = re.match('.*(EXAMPLE_END).*',line)
|
parts = re.match('.*(EXAMPLE_END).*',line)
|
||||||
if parts:
|
if parts:
|
||||||
if state != State.SearchListingStart:
|
if state != State.SearchListingStart:
|
||||||
print "Formating error detected"
|
print("Formating error detected")
|
||||||
writeItemizeBlock(aout, 0)
|
writeItemizeBlock(aout, 0)
|
||||||
writeTextBlock(aout, 0)
|
writeTextBlock(aout, 0)
|
||||||
state = State.ReachedExampleEnd
|
state = State.ReachedExampleEnd
|
||||||
print "Reached end of the example"
|
print("Reached end of the example")
|
||||||
|
|
||||||
|
|
||||||
# write list of examples
|
# write list of examples
|
||||||
def processExamples(intro_file, examples_folder, examples_ofile):
|
def processExamples(intro_file, examples_folder, examples_ofile):
|
||||||
with open(examples_ofile, 'w') as aout:
|
with open(examples_ofile, 'w') as aout:
|
||||||
with open(intro_file, 'rb') as fin:
|
with open(intro_file, 'r') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
aout.write(line)
|
aout.write(line)
|
||||||
|
|
||||||
for group_title in list_of_groups:
|
for group_title in list_of_groups:
|
||||||
if not list_of_examples.has_key(group_title): continue
|
if not group_title in list_of_examples: continue
|
||||||
examples = list_of_examples[group_title]
|
examples = list_of_examples[group_title]
|
||||||
for example in examples:
|
for example in examples:
|
||||||
example_path = examples_folder + example[0] + ".c"
|
example_path = examples_folder + example[0] + ".c"
|
||||||
@ -282,7 +282,7 @@ def processExamples(intro_file, examples_folder, examples_ofile):
|
|||||||
aout.write("\n\n");
|
aout.write("\n\n");
|
||||||
|
|
||||||
for group_title in list_of_groups:
|
for group_title in list_of_groups:
|
||||||
if not list_of_examples.has_key(group_title): continue
|
if not group_title in list_of_examples: continue
|
||||||
examples = list_of_examples[group_title]
|
examples = list_of_examples[group_title]
|
||||||
|
|
||||||
group_title = group_title + " example"
|
group_title = group_title + " example"
|
||||||
@ -300,7 +300,7 @@ def processExamples(intro_file, examples_folder, examples_ofile):
|
|||||||
aout.write("\n")
|
aout.write("\n")
|
||||||
|
|
||||||
for group_title in list_of_groups:
|
for group_title in list_of_groups:
|
||||||
if not list_of_examples.has_key(group_title): continue
|
if not group_title in list_of_examples: continue
|
||||||
examples = list_of_examples[group_title]
|
examples = list_of_examples[group_title]
|
||||||
|
|
||||||
for example in examples:
|
for example in examples:
|
||||||
@ -320,11 +320,11 @@ def main(argv):
|
|||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(argv,"hiso:",["ffolder=","ifile=","ofile="])
|
opts, args = getopt.getopt(argv,"hiso:",["ffolder=","ifile=","ofile="])
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
print cmd
|
print (cmd)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
if opt == '-h':
|
if opt == '-h':
|
||||||
print cmd
|
print (cmd)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
elif opt in ("-f", "--ffolder"):
|
elif opt in ("-f", "--ffolder"):
|
||||||
inputfolder = arg
|
inputfolder = arg
|
||||||
@ -332,9 +332,9 @@ def main(argv):
|
|||||||
introfile = arg
|
introfile = arg
|
||||||
elif opt in ("-o", "--ofile"):
|
elif opt in ("-o", "--ofile"):
|
||||||
outputfile = arg
|
outputfile = arg
|
||||||
print 'Input folder is ', inputfolder
|
print ('Input folder is : ', inputfolder)
|
||||||
print 'Intro file is ', introfile
|
print ('Intro file is : ', introfile)
|
||||||
print 'Output file is ', outputfile
|
print ('Output file is : ', outputfile)
|
||||||
|
|
||||||
processExamples(introfile, inputfolder, outputfile)
|
processExamples(introfile, inputfolder, outputfile)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user