Skip to content

Commit aeb53d5

Browse files
authored
Merge pull request #9227 from wazuh/enhancement/idr560-create-llms-ready-documentation-4.9
Add Markdown files creation support 4.9
2 parents 8240a5b + c229624 commit aeb53d5

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) sou
1919
# the i18n builder cannot share the environment and doctrees with the others
2020
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
2121

22-
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext
22+
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext markdown
2323

2424
help:
2525
@echo "Please use \`make <target>' where <target> is one of"
26+
@echo " markdown to make Markdown files"
2627
@echo " html-prod to make standalone HTML files, including GA code. Production only"
2728
@echo " html-dev to make standalone HTML files, without GA code. Development only"
2829
@echo " html-quick to make standalone HTML files using parallel processing"
@@ -56,14 +57,20 @@ clean:
5657

5758
theme:
5859
@cd source/_themes/wazuh_doc_theme_v3 && npm run build-all
59-
@echo
60+
@echo
6061
@echo Build finished. The main theme assets has been updated.
6162
@cd ../../..
6263
@echo
6364

6465
search-index:
6566
npx -y pagefind@v1.1.0 --site $(BUILDDIR)/html --force-language en
6667

68+
markdown:
69+
$(SPHINXBUILD) -b markdown $(ALLSPHINXOPTS) $(BUILDDIR)/markdown
70+
@echo
71+
@echo "Build finished. The Markdown files are in $(BUILDDIR)/markdown."
72+
@echo
73+
6774
html-production:
6875
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html -t production
6976
@echo
@@ -80,17 +87,17 @@ html-quick:
8087
$(SPHINXBUILD) -j auto -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
8188
@echo
8289
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
83-
90+
8491
html:
8592
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
8693
@echo
8794
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
8895
@echo
8996

9097
html-prod: html-production search-index
91-
98+
9299
html-dev: html-development search-index
93-
100+
94101
html-search: html search-index
95102

96103
dirhtml:

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
Sphinx==7.2.6
1+
Sphinx==7.3.7
22
sphinx-tabs==3.4.5
33
docutils==0.18.1
44
jsmin==3.0.1
55
Jinja2==3.1.6
66
Pygments==2.15.1
7-
sphinx-reredirects==0.1.5
7+
sphinx-reredirects==0.1.5
8+
sphinx-markdown-builder==0.6.9

source/conf.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
'sphinx.ext.extlinks', # Sphinx built-in extension
5656
'sphinx_tabs.tabs',
5757
'wazuh-doc-images', # Custom extension
58-
'sphinx_reredirects'
58+
'sphinx_reredirects',
59+
'sphinx_markdown_builder'
5960
]
6061

6162
# Add any paths that contain templates here, relative to this directory.
@@ -148,7 +149,7 @@
148149
current_release[0] == v3_release[0] and
149150
current_release[1] < v3_release[1])
150151
html_theme_options['is_pre_v3'] = is_pre_v3
151-
152+
152153
# Allow dark mode is set to false by default
153154
html_theme_options['include_mode'] = True
154155
# Allow switching between modes is set to false by default
@@ -241,7 +242,7 @@
241242
# Add link anchors for each heading and description environment. Default: True.
242243
html_permalinks = True
243244

244-
# Text for link anchors for each heading and description environment. HTML entities
245+
# Text for link anchors for each heading and description environment. HTML entities
245246
# and Unicode are allowed. Default: a paragraph sign; ¶
246247
html_permalinks_icon = ''
247248

@@ -370,6 +371,10 @@
370371
# A list of files that should not be packed into the epub file.
371372
epub_exclude_files = ['search.html', 'not_found.html']
372373

374+
# -- Options for Markdown output --------------------------------------------
375+
376+
# Options for sphinx-markdown-builder
377+
markdown_http_base = '' # Use relative links
373378

374379
# -- Extension configuration -------------------------------------------------
375380

@@ -435,7 +440,7 @@ def setup(app):
435440
os.mkdir(static_path_str)
436441

437442
if html_theme == 'wazuh_doc_theme_v3':
438-
443+
439444
# Download spec file if the file is missing or older that spec_max_age
440445
if api_tag != '' and apiURL != '':
441446
spec_max_age = 60*15 # 15 minutes
@@ -450,7 +455,7 @@ def setup(app):
450455
except FileNotFoundError:
451456
print(server_api_spec_path + " not found")
452457
download_needed = True
453-
458+
454459
if download_needed == True:
455460
print ('Downloading ' + 'spec-'+api_tag+'.yaml')
456461
spec_path, url_retrieve_headers = urlretrieve(apiURL, server_api_spec_path)
@@ -633,16 +638,16 @@ def finish_and_clean(app, exception):
633638
os.remove(mapFilePath)
634639
except:
635640
print("Error while deleting file : ", mapFilePath)
636-
641+
637642
# Remove the source mapping URLs
638643
for assetsFilePath in assetsFiles:
639644
try:
640645
with open(assetsFilePath, "r") as f:
641646
lines = f.readlines()
642647
with open(assetsFilePath, "w") as f:
643648
for line in lines:
644-
line = re.sub("//# sourceMappingURL=.*\.map", "", line)
645-
line = re.sub("/\*# sourceMappingURL=.*\.map \*/", "", line)
649+
line = re.sub(r"//# sourceMappingURL=.*\.map", "", line)
650+
line = re.sub(r"/\*# sourceMappingURL=.*\.map \*/", "", line)
646651
f.write(line)
647652
except:
648653
print("Error while removing source mapping from file: ", assetsFilePath)

0 commit comments

Comments
 (0)