Skip to content

Commit

Permalink
Merge branch 'feat/fix_build_pdf_and_add_post_pdf_link' into 'master'
Browse files Browse the repository at this point in the history
feat: Fix build pdf and post pdf links

Closes DOC-10232

See merge request ae_group/esp-dev-kits!279
  • Loading branch information
Zhang Shu Xian committed Feb 18, 2025
2 parents ccea338 + 3a7dd39 commit bad04b2
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 53 deletions.
10 changes: 3 additions & 7 deletions .gitlab/ci/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ build_docs_html:
- docs/_build/*/*/*.txt
- docs/_build/*/*/html/*
expire_in: 4 days
variables:
DOC_BUILDERS: "html"
retry: 2

build_docs_pdf:
Expand All @@ -41,15 +39,13 @@ build_docs_pdf:
- cd docs
- ./check_lang_folder_sync.sh
- python -m pip install -r requirements.txt
- build-docs --skip-reqs-check -l $DOCLANG -t $DOCTGT
- echo "esp-dev-kits documentation preview in PDF is available at:"
- echo "$CI_JOB_URL/artifacts/file/docs/_build/$DOCLANG/$DOCTGT/latex/build/esp-dev-kits-$DOCLANG-master-$DOCTGT.pdf"
- build-docs --skip-reqs-check -bs latex -l $DOCLANG -t $DOCTGT
- ARTIFACT_URL="$CI_JOB_URL/artifacts/file/docs/_build/$DOCLANG/$DOCTGT/latex/build/esp-dev-kits-$DOCLANG-master-$DOCTGT.pdf"
- echo "esp-dev-kits documentation preview in PDF is available at $ARTIFACT_URL"
artifacts:
when: always
paths:
- docs/_build/*/*/latex/*
- docs/_build/*/*/*.txt
expire_in: 4 days
variables:
DOC_BUILDERS: "latex"
retry: 2
6 changes: 3 additions & 3 deletions docs/en/esp-module-prog-1-r/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ ESP-Module-Prog-1(R)

:link_to_translation:`zh_CN:[中文]`

This user guide will help you get started with ESP-Module-Prog-1(R) and will also provide more in-depth information.
This user guide will help you get started with ESP-Module-Prog-1(R) and provide in-depth information of this board.

ESP-Module-Prog-1 and ESP-Module-Prog-1R (R stands for WROVER) are two flashing mainboards produced by Espressif. They can be used to flash modules without soldering the module to the power supply and signal lines. The mainboard can be used independently or in combination with a subboard. Espressif supports two subboards: ESP-Module-Prog-SUB-02 and ESP-Module-Prog-SUB-01&04, which cannot be used independently and must be used in conjunction with any of the above-mentioned mainboards.
ESP-Module-Prog-1 and ESP-Module-Prog-1R (R stands for WROVER) are two flashing mainboards produced by Espressif. These mainboards allow you to flash modules without the need for soldering to the power supply and signal lines. They can be used as standalone devices or in combination with a subboard. Espressif supports two subboards: ESP-Module-Prog-SUB-02 and ESP-Module-Prog-SUB-01&04, which cannot be used independently and must be used in conjunction with any of the above-mentioned mainboards.

This user guide will introduce **ESP-Module-Prog-1(R) Mainboard**. For detailed information about the subboards, please click the links below and check the corresponding user guides.
This user guide focuses on **ESP-Module-Prog-1(R) Mainboard**. For detailed information about the subboards, please click the links below and check the corresponding user guides.

- :doc:`../esp-module-prog-sub-01&04/user_guide`
- :doc:`../esp-module-prog-sub-02/user_guide`
Expand Down
128 changes: 85 additions & 43 deletions post-mr-note.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,54 @@ def __init__(self, url, authkey, project, mr_iid):


def collect_data(self):
series_links = {}
with open("logs/doc-url.txt", "r") as file:
for line in file:
if line.startswith('[document preview]'):
tokens = line.split(']')
desc_url = tokens[2]
lang_chip_info = tokens[1]
lang_chip = lang_chip_info.strip(']').strip('[').split('_')

if len(lang_chip) == 2:
language = 'en'
chip_series = lang_chip[1]
elif len(lang_chip) == 3:
language = 'zh_CN'
chip_series = lang_chip[2]
else:
continue

language_links = series_links.get(chip_series, {})
language_links[language] = desc_url
series_links[chip_series] = language_links

self.series_links = series_links
print(series_links) # Debugging line

"""
Read document URLs from logs and organize them by language and chip series.
"""
series_links_html = {}
series_links_pdf = {}

try:
with open("logs/doc-url.txt", "r") as file:
for line in file:
if line.startswith('[document preview]'):
tokens = line.split(']')
if len(tokens) < 3:
continue

desc_url = tokens[2].strip()
lang_chip_info = tokens[1].strip('[]')
lang_chip = lang_chip_info.split('_')

if len(lang_chip) == 2:
language = 'en'
chip_series = lang_chip[1]
elif len(lang_chip) == 3:
language = 'zh_CN'
chip_series = lang_chip[2]
else:
continue # Skip malformed lines

# Construct new PDF URL
pdf_url = desc_url.replace(
"index.html",
f"esp-dev-kits-{language}-master-{chip_series}.pdf"
)

# Store links
if 'pdf' in pdf_url:
series_links_pdf.setdefault(chip_series, {})[language] = pdf_url
if 'html' in desc_url:
series_links_html.setdefault(chip_series, {})[language] = desc_url
except FileNotFoundError:
print("Error: logs/doc-url.txt not found.")
sys.exit(1)

self.series_links_html = series_links_html
self.series_links_pdf = series_links_pdf

# Debugging line
print("HTML Links:", series_links_html)
print("PDF Links:", series_links_pdf)

def prepare_note(self):
"""
Expand All @@ -80,27 +103,46 @@ def prepare_note(self):
note = "Documentation preview:\n\n"

product_names = {
'esp32': 'ESP32',
'esp32s2': 'ESP32-S2',
'esp32s3': 'ESP32-S3',
'esp32c3': 'ESP32-C3',
'esp32c6': 'ESP32-C6',
'esp32h2': 'ESP32-H2',
'esp32c2': 'ESP32-C2',
'esp32p4': 'ESP32-P4',
'esp32c5': 'ESP32-C5',
'esp32c61': 'ESP32-C61',
'other': 'Other'
'esp32': 'ESP32', 'esp32s2': 'ESP32-S2', 'esp32s3': 'ESP32-S3',
'esp32c3': 'ESP32-C3', 'esp32c6': 'ESP32-C6', 'esp32h2': 'ESP32-H2',
'esp32c2': 'ESP32-C2', 'esp32p4': 'ESP32-P4', 'esp32c5': 'ESP32-C5',
'esp32c61': 'ESP32-C61', 'other': 'Other'
}

for chip_series, language_links in self.series_links.items():
product_name = product_names.get(chip_series, chip_series.upper())
zh_cn_link = f"[esp-dev-kits 文档]({language_links.get('zh_CN', 'esp-dev-kits 文档')})"
en_link = f"[esp-dev-kits Documentation]({language_links.get('en', 'esp-dev-kits Documentation')})"
# Combine the links with a slash
note += f"- {product_name}: {zh_cn_link}/{en_link}\n"

# Process both HTML and PDF links
for chip_series, language_links_html in self.series_links_html.items():
product_name = product_names.get(chip_series, "Unknown")
note += f"- **{product_name}**\n"

# Append HTML link if available
if 'zh_CN' in language_links_html:
note += f"\t * HTML: [esp-dev-kits 文档]({language_links_html['zh_CN']})/"
else:
note += f"esp-dev-kits 文档/"
if 'en' in language_links_html:
note += f"[esp-dev-kits Documentation]({language_links_html['en']}) \n"
else:
note += "esp-dev-kits Documentation"

# Check if there are PDF links for the same chip series
if chip_series in self.series_links_pdf:
language_links_pdf = self.series_links_pdf[chip_series]
if 'zh_CN' in language_links_pdf:
note += f"\t * PDF: [esp-dev-kits 文档]({language_links_pdf['zh_CN']})/"
else:
note += f"esp-dev-kits 文档/"
if 'en' in language_links_pdf:
note += f"[esp-dev-kits Documentation]({language_links_pdf['en']}) \n"
else:
note += "esp-dev-kits Documentation"

note += "\n"


# Store the note in the instance variable
self.note = note

# Print the note for debugging
print(note)

def post_note(self):
Expand Down

0 comments on commit bad04b2

Please sign in to comment.