docs: add readme files from ports to a new chapter on existing ports

This commit is contained in:
Milanka Ringwald 2017-12-22 23:18:46 +01:00
parent 63e0421ec0
commit 41026ca603
5 changed files with 81 additions and 2 deletions

View File

@ -5,6 +5,7 @@ html:
rm -rf docs_final
cp -r docs docs_tmp
cp -r docs docs_final
./ports2markdown.py
./markdown2mkdocs.py
rm -rf docs_tmp
mkdocs build --clean
@ -13,6 +14,7 @@ html:
pdf:
mkdir -p latex
cp -r docs/picts latex
./ports2markdown.py
./markdown2pdf.py
cp btstack_gettingstarted.tex latex
cd latex && pdflatex btstack_gettingstarted.tex && pdflatex btstack_gettingstarted.tex
@ -20,12 +22,12 @@ pdf:
rm -rf latex tmp
preview: update_docs_and_apis html
preview: update_apis html
# race condition, open browser before startnig MKdocs
open http://127.0.0.1:8000
mkdocs serve
update_docs_and_apis:
update_apis:
sed -e "s|../doc/manual/docs/||g" ../../chipset/README.md > docs/chipsets.md
rm -rf tmp
mkdir tmp

1
doc/manual/docs/ports/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
existing_ports.md

View File

@ -0,0 +1 @@
Here is a list of existing ports:

View File

@ -12,6 +12,7 @@ pages:
- [examples/examples.md, Embedded Examples]
- [chipsets.md, Chipsets]
- [porting.md, Porting to Other Platforms]
- [ports/existing_ports.md, Existing Ports]
- [integration.md, Integrating with Existing Systems]
- [appendix/apis.md, APIs]
- [appendix/events_errors.md, Events and Errors]

74
doc/manual/ports2markdown.py Executable file
View File

@ -0,0 +1,74 @@
#!/usr/bin/env python
import sys, os, shutil
import re, yaml
import fnmatch
blacklist = []
example_item = """
- [PORT_TITLE](#sec:PORT_LABELPort): PORT_PATH"""
def get_readme_title(example_path):
title = ''
with open(example_path, 'rb') as fin:
for line in fin:
parts = re.match('(##\s)(.*)\n',line)
if parts:
title = parts.group(2)
continue
return title
# write list of examples
def process_readmes(intro_file, ports_folder, ports_file):
matches = {}
for root, dirnames, filenames in os.walk(ports_folder):
for filename in fnmatch.filter(filenames, 'README.md'):
folder = os.path.basename(root)
if folder not in blacklist:
matches[folder] = os.path.join(root, filename)
with open(ports_file, 'w') as ports:
with open(intro_file, 'rb') as fin:
for line in fin:
ports.write(line)
fin.close()
for readme_dir, readme_file in matches.items():
with open(readme_file, 'rb') as fin:
for line in fin:
#increase level of indetation
parts = re.match('(#\s+)(.*)\n',line)
if parts:
title = parts.group(2)
ports.write(example_item.replace("PORT_TITLE", title).replace("PORT_PATH", readme_file).replace("PORT_LABEL", readme_dir))
break
fin.close()
ports.write("\n\n")
for readme_dir, readme_file in matches.items():
with open(readme_file, 'rb') as fin:
for line in fin:
#increase level of indetation
parts = re.match('#(.*\n)',line)
if parts:
ports.write("#" + line + "{#sec:"+ readme_dir + "Port}")
else:
ports.write(line)
fin.close()
ports.close()
def main(argv):
btstackfolder = "../../"
docsfolder = "docs/"
inputfolder = btstackfolder + "port/"
introfile = docsfolder + "ports/intro.md"
outputfile = docsfolder + "ports/existing_ports.md"
process_readmes(introfile, inputfolder, outputfile)
if __name__ == "__main__":
main(sys.argv[1:])