Skip to content

Commit

Permalink
Fix usage of PICO_EXAMPLES_PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
lurch committed Aug 13, 2024
1 parent 1458333 commit e366783
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ clean_submodules:

# Create the pico-sdk Doxygen XML files
$(DOXYGEN_XML_DIR) $(DOXYGEN_XML_DIR)/index.xml: | $(ALL_SUBMODULE_CMAKELISTS) $(DOXYGEN_PICO_SDK_BUILD_DIR)
cmake -S $(PICO_SDK_DIR) -B $(DOXYGEN_PICO_SDK_BUILD_DIR)/combined -D PICO_EXAMPLES_PATH=../$(PICO_EXAMPLES_DIR) -D PICO_PLATFORM=combined-docs
cmake -S $(PICO_SDK_DIR) -B $(DOXYGEN_PICO_SDK_BUILD_DIR)/PICO_RP2040 -D PICO_EXAMPLES_PATH=../$(PICO_EXAMPLES_DIR) -D PICO_PLATFORM=rp2040
cmake -S $(PICO_SDK_DIR) -B $(DOXYGEN_PICO_SDK_BUILD_DIR)/PICO_RP2350 -D PICO_EXAMPLES_PATH=../$(PICO_EXAMPLES_DIR) -D PICO_PLATFORM=rp2350
cmake -S $(PICO_SDK_DIR) -B $(DOXYGEN_PICO_SDK_BUILD_DIR)/combined -D PICO_EXAMPLES_PATH=../../$(PICO_EXAMPLES_DIR) -D PICO_PLATFORM=combined-docs
cmake -S $(PICO_SDK_DIR) -B $(DOXYGEN_PICO_SDK_BUILD_DIR)/PICO_RP2040 -D PICO_EXAMPLES_PATH=../../$(PICO_EXAMPLES_DIR) -D PICO_PLATFORM=rp2040
cmake -S $(PICO_SDK_DIR) -B $(DOXYGEN_PICO_SDK_BUILD_DIR)/PICO_RP2350 -D PICO_EXAMPLES_PATH=../../$(PICO_EXAMPLES_DIR) -D PICO_PLATFORM=rp2350
$(MAKE) -C $(DOXYGEN_PICO_SDK_BUILD_DIR)/combined docs
$(MAKE) -C $(DOXYGEN_PICO_SDK_BUILD_DIR)/PICO_RP2040 docs
$(MAKE) -C $(DOXYGEN_PICO_SDK_BUILD_DIR)/PICO_RP2350 docs
Expand Down
5 changes: 2 additions & 3 deletions scripts/create_build_adoc_doxygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ def check_no_markdown(filename):
asciidoc = re.sub(r'----\n.*?\n----', '', asciidoc, flags=re.DOTALL)
# strip out pass-through blocks
asciidoc = re.sub(r'\+\+\+\+\n.*?\n\+\+\+\+', '', asciidoc, flags=re.DOTALL)
# This is messing up the c code blocks
# if re.search(r'(?:^|\n)#+', asciidoc):
# raise Exception("{} contains a Markdown-style header (i.e. '#' rather than '=')".format(filename))
if re.search(r'(?:^|\n)#+', asciidoc):
raise Exception("{} contains a Markdown-style header (i.e. '#' rather than '=')".format(filename))
if re.search(r'(\[.+?\]\(.+?\))', asciidoc):
raise Exception("{} contains a Markdown-style link (i.e. '[title](url)' rather than 'url[title]')".format(filename))

Expand Down
54 changes: 28 additions & 26 deletions scripts/postprocess_doxygen_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
import re
import os
import html
#import html
from bs4 import BeautifulSoup

# walk the combined output.
Expand All @@ -18,30 +18,31 @@ def compile_id_list(xml_content):
id_list = [x["id"] for x in els]
return id_list

def insert_example_code_from_file(combined_content):
els = combined_content.doxygen.find_all("programlisting")
all_examples = {}
# get the examples path
examples_path = re.sub(r"/scripts/.+$", "/lib/pico-examples", os.path.realpath(__file__))
# get a recursive list of all files in examples
for f in os.walk(examples_path):
for filename in f[2]:
if filename in all_examples:
all_examples[filename].append(os.path.join(f[0], filename))
else:
all_examples[filename] = [os.path.join(f[0], filename)]
for el in els:
if el.get("filename") is not None:
filename = el.get("filename")
# find the file here or in examples
if filename in all_examples:
with open(all_examples[filename][0]) as f:
example_content = f.read()
example_lines = example_content.split("\n")
for line in example_lines:
codeline = BeautifulSoup("<codeline>"+html.escape(line)+"</codeline>", 'xml')
el.append(codeline)
return combined_content
# Unused code - but kept in case we need it in future
#def insert_example_code_from_file(combined_content):
# els = combined_content.doxygen.find_all("programlisting")
# all_examples = {}
# # get the examples path
# examples_path = re.sub(r"/scripts/.+$", "/lib/pico-examples", os.path.realpath(__file__))
# # get a recursive list of all files in examples
# for f in os.walk(examples_path):
# for filename in f[2]:
# if filename in all_examples:
# all_examples[filename].append(os.path.join(f[0], filename))
# else:
# all_examples[filename] = [os.path.join(f[0], filename)]
# for el in els:
# if el.get("filename") is not None:
# filename = el.get("filename")
# # find the file here or in examples
# if filename in all_examples:
# with open(all_examples[filename][0]) as f:
# example_content = f.read()
# example_lines = example_content.split("\n")
# for line in example_lines:
# codeline = BeautifulSoup("<codeline>"+html.escape(line)+"</codeline>", 'xml')
# el.append(codeline)
# return combined_content

def walk_and_tag_xml_tree(el, output_contexts, all_contexts):
"""
Expand Down Expand Up @@ -123,7 +124,8 @@ def postprocess_doxygen_xml_file(combined_xmlfile, xmlfiles, output_context_path
els = combined_content.doxygen.find_all(True, recursive=False)
for el in els:
walk_and_tag_xml_tree(el, output_contexts, list(output_context_paths.keys()))
combined_content = insert_example_code_from_file(combined_content)
# I think this was only needed because the PICO_EXAMPLES_PATH was wrong in the Makefile
#combined_content = insert_example_code_from_file(combined_content)
return str(combined_content)

def postprocess_doxygen_xml(xml_path):
Expand Down

0 comments on commit e366783

Please sign in to comment.