Skip to contentSkip to conversation

dts: remove html dir from dts doc path

PATCH In review Paul Szczepanek 2 participants 9 messages Nov 26, 2024 – Nov 29, 2024 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dts: remove html dir from dts doc path

To facilitate deploying docs to the website
and make paths more consistent remove the html directory from the dts doc path.

---
 buildtools/call-sphinx-build.py | 5 +++--
 doc/api/meson.build             | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
buildtools/call-sphinx-build.py +3 -2
index 2c7de54285..93ed81ac88 100755
@@ -30,8 +30,9 @@
 
 # run sphinx, putting the html output in a "html" directory
 with open(join(dst, 'sphinx_html.out'), 'w') as out:
-    process = run(sphinx_cmd + ['-b', 'html', src, join(dst, 'html')],
-                  stdout=out)
+    # dts is a special case which doesn't require an html dir in destination path
+    html_dst = dst if 'dts' in src else join(dst, 'html')
+    process = run(sphinx_cmd + ['-b', 'html', src, html_dst], stdout=out)
 
 # create a gcc format .d file giving all the dependencies of this doc build
 with open(join(dst, '.html.d'), 'w') as d:
doc/api/meson.build +1 -1
index f9f1326bbd..ac6eb8236d 100644
@@ -37,7 +37,7 @@ cdata.set('OUTPUT', join_paths(dpdk_build_root, 'doc', 'api'))
 cdata.set('TOPDIR', dpdk_source_root)
 cdata.set('STRIP_FROM_PATH', ' '.join([dpdk_source_root, join_paths(dpdk_build_root, 'doc', 'api')]))
 cdata.set('WARN_AS_ERROR', 'NO')
-cdata.set('DTS_API_MAIN_PAGE', join_paths('.', 'dts', 'html', 'index.html'))
+cdata.set('DTS_API_MAIN_PAGE', join_paths('.', 'dts', 'index.html'))
 if get_option('werror')
     cdata.set('WARN_AS_ERROR', 'YES')
 endif
Signature · 1 line
2.39.2
#1 lore raw

26/11/2024 17:25, Paul Szczepanek:

buildtools/call-sphinx-build.py line 33

Quoted 12 lines

To facilitate deploying docs to the website
and make paths more consistent remove the html directory from the dts doc path.

---

 # run sphinx, putting the html output in a "html" directory
 with open(join(dst, 'sphinx_html.out'), 'w') as out:
buildtools/call-sphinx-build.py +1 -2
-    process = run(sphinx_cmd + ['-b', 'html', src, join(dst, 'html')],
-                  stdout=out)
+    # dts is a special case which doesn't require an html dir in destination path

The comment could be simpler like:
# DTS API doc is already located in the API html dir

Quoted 1 line

+ html_dst = dst if 'dts' in src else join(dst, 'html')

This check is too weak.
It would be better to check for /html/dts in dst
or for /html/ in 1 of the last 2 path children.

Quoted 1 line

+ process = run(sphinx_cmd + ['-b', 'html', src, html_dst], stdout=out)

#2 lore raw

PATCH v2 1/1 docs: remove html dir from nested docs

In reply to Paul Szczepanek

To facilitate deploying docs to the website
and make paths more consistent remove the html directory from nested docs.

---
 buildtools/call-sphinx-build.py | 7 +++++--
 doc/api/meson.build             | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
buildtools/call-sphinx-build.py +5 -2
index 2c7de54285..fa245afa73 100755
@@ -30,8 +30,11 @@
 
 # run sphinx, putting the html output in a "html" directory
 with open(join(dst, 'sphinx_html.out'), 'w') as out:
-    process = run(sphinx_cmd + ['-b', 'html', src, join(dst, 'html')],
-                  stdout=out)
+    # don't append html dir if dst is already nested in one but first
+    # remove the part of the path outside the tree in case html dir exists there
+    rel_path = os.path.relpath(dst, os.path.dirname(__file__))
+    html_dst = dst if 'html' in rel_path else join(dst, 'html')
+    process = run(sphinx_cmd + ['-b', 'html', src, html_dst], stdout=out)
 
 # create a gcc format .d file giving all the dependencies of this doc build
 with open(join(dst, '.html.d'), 'w') as d:
doc/api/meson.build +1 -1
index f9f1326bbd..ac6eb8236d 100644
@@ -37,7 +37,7 @@ cdata.set('OUTPUT', join_paths(dpdk_build_root, 'doc', 'api'))
 cdata.set('TOPDIR', dpdk_source_root)
 cdata.set('STRIP_FROM_PATH', ' '.join([dpdk_source_root, join_paths(dpdk_build_root, 'doc', 'api')]))
 cdata.set('WARN_AS_ERROR', 'NO')
-cdata.set('DTS_API_MAIN_PAGE', join_paths('.', 'dts', 'html', 'index.html'))
+cdata.set('DTS_API_MAIN_PAGE', join_paths('.', 'dts', 'index.html'))
 if get_option('werror')
     cdata.set('WARN_AS_ERROR', 'YES')
 endif

--
2.39.2

#3 lore raw

Re: [PATCH v2] docs: remove html dir from nested docs

27/11/2024 12:41, Paul Szczepanek:

buildtools/call-sphinx-build.py line 36

Quoted 4 lines
buildtools/call-sphinx-build.py +4 -0
+    # don't append html dir if dst is already nested in one but first
+    # remove the part of the path outside the tree in case html dir exists there
+    rel_path = os.path.relpath(dst, os.path.dirname(__file__))
+    html_dst = dst if 'html' in rel_path else join(dst, 'html')

What happens if the build directory is a completely different path of the source tree?
Is there a risk of having the build directory inside a tree having /html/?

#4 lore raw

PATCH v3 1/1 dts: remove html dir from nested docs

In reply to Paul Szczepanek

To facilitate deploying docs to the website
and make paths more consistent remove the html directory from docs nested in html directories.

---
 buildtools/call-sphinx-build.py | 6 ++++--
 doc/api/meson.build             | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)
buildtools/call-sphinx-build.py +4 -2
index 2c7de54285..3e5fc813a2 100755
@@ -30,8 +30,10 @@
 
 # run sphinx, putting the html output in a "html" directory
 with open(join(dst, 'sphinx_html.out'), 'w') as out:
-    process = run(sphinx_cmd + ['-b', 'html', src, join(dst, 'html')],
-                  stdout=out)
+    # don't append html dir if dst is already nested in a html dir
+    top_2_dirs = os.path.join(*os.path.normpath(dst).split(os.path.sep)[-2:])
+    html_dst = dst if 'html' in top_2_dirs else join(dst, 'html')
+    process = run(sphinx_cmd + ['-b', 'html', src, html_dst], stdout=out)
 
 # create a gcc format .d file giving all the dependencies of this doc build
 with open(join(dst, '.html.d'), 'w') as d:
doc/api/meson.build +1 -1
index f9f1326bbd..ac6eb8236d 100644
@@ -37,7 +37,7 @@ cdata.set('OUTPUT', join_paths(dpdk_build_root, 'doc', 'api'))
 cdata.set('TOPDIR', dpdk_source_root)
 cdata.set('STRIP_FROM_PATH', ' '.join([dpdk_source_root, join_paths(dpdk_build_root, 'doc', 'api')]))
 cdata.set('WARN_AS_ERROR', 'NO')
-cdata.set('DTS_API_MAIN_PAGE', join_paths('.', 'dts', 'html', 'index.html'))
+cdata.set('DTS_API_MAIN_PAGE', join_paths('.', 'dts', 'index.html'))
 if get_option('werror')
     cdata.set('WARN_AS_ERROR', 'YES')
 endif
Signature · 1 line
2.39.2
#5 lore raw

Re: [PATCH v3] dts: remove html dir from nested docs

29/11/2024 00:05, Paul Szczepanek:

Quoted 16 lines

To facilitate deploying docs to the website
and make paths more consistent remove the html directory from docs nested in html directories.

---
 buildtools/call-sphinx-build.py | 6 ++++--
 doc/api/meson.build             | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)
buildtools/call-sphinx-build.py +0 -0
index 2c7de54285..3e5fc813a2 100755

buildtools/call-sphinx-build.py line 36

Quoted 9 lines
buildtools/call-sphinx-build.py +4 -2
@@ -30,8 +30,10 @@
 
 # run sphinx, putting the html output in a "html" directory
 with open(join(dst, 'sphinx_html.out'), 'w') as out:
-    process = run(sphinx_cmd + ['-b', 'html', src, join(dst, 'html')],
-                  stdout=out)
+    # don't append html dir if dst is already nested in a html dir
+    top_2_dirs = os.path.join(*os.path.normpath(dst).split(os.path.sep)[-2:])
+    html_dst = dst if 'html' in top_2_dirs else join(dst, 'html')
+    process = run(sphinx_cmd + ['-b', 'html', src, html_dst], stdout=out)

There is still a file in the extra html directory:

build/doc/api/html/dts/html/_static/css/custom.css

I suppose that we need to change this line:

dst_css = join(dst, 'html', '_static', 'css', css)

into

dst_css = join(html_dst, '_static', 'css', css)

Then it should become this path:

build/doc/api/html/dts/_static/css/custom.css

#6 lore raw

PATCH v4 1/1 dts: remove nested html dir for API doc

In reply to Paul Szczepanek

From: Paul Szczepanek <[email protected]>

To facilitate deploying docs to the website
and make paths more consistent remove the html directory from docs nested in API html directory.

---
v4: fix custom.css path and reword a little

---
 buildtools/call-sphinx-build.py | 8 +++++---
 doc/api/meson.build             | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)
buildtools/call-sphinx-build.py +5 -3
index 2c7de54285..c891f68ae4 100755
@@ -30,8 +30,10 @@
 
 # run sphinx, putting the html output in a "html" directory
 with open(join(dst, 'sphinx_html.out'), 'w') as out:
-    process = run(sphinx_cmd + ['-b', 'html', src, join(dst, 'html')],
-                  stdout=out)
+    # don't append html dir if dst is already nested in a html dir
+    last_two_dirs = os.path.join(*os.path.normpath(dst).split(os.path.sep)[-2:])
+    html_dst = dst if 'html' in last_two_dirs else join(dst, 'html')
+    process = run(sphinx_cmd + ['-b', 'html', src, html_dst], stdout=out)
 
 # create a gcc format .d file giving all the dependencies of this doc build
 with open(join(dst, '.html.d'), 'w') as d:
@@ -40,7 +42,7 @@
 # copy custom CSS file
 css = 'custom.css'
 src_css = join(src, css)
-dst_css = join(dst, 'html', '_static', 'css', css)
+dst_css = join(html_dst, '_static', 'css', css)
 if not os.path.exists(dst_css) or not filecmp.cmp(src_css, dst_css):
     os.makedirs(os.path.dirname(dst_css), exist_ok=True)
     shutil.copyfile(src_css, dst_css)
doc/api/meson.build +1 -1
index f9f1326bbd..ac6eb8236d 100644
@@ -37,7 +37,7 @@ cdata.set('OUTPUT', join_paths(dpdk_build_root, 'doc', 'api'))
 cdata.set('TOPDIR', dpdk_source_root)
 cdata.set('STRIP_FROM_PATH', ' '.join([dpdk_source_root, join_paths(dpdk_build_root, 'doc', 'api')]))
 cdata.set('WARN_AS_ERROR', 'NO')
-cdata.set('DTS_API_MAIN_PAGE', join_paths('.', 'dts', 'html', 'index.html'))
+cdata.set('DTS_API_MAIN_PAGE', join_paths('.', 'dts', 'index.html'))
 if get_option('werror')
     cdata.set('WARN_AS_ERROR', 'YES')
 endif
Signature · 1 line
2.47.1
author Reviewed-by on v4 1/1
#7 lore raw

Re: [PATCH v4] dts: remove nested html dir for API doc

Quoted 10 lines · Thomas Monjalon

From: Paul Szczepanek <[email protected]>

To facilitate deploying docs to the website
and make paths more consistent remove the html directory from docs nested in API html directory.

---

Makes sense to remove the html from the css, thanks.

Won't the scripts complain about the order of tags? Signed off should come before reviewed.

#8 lore raw

Re: [PATCH v4] dts: remove nested html dir for API doc

29/11/2024 13:15, Paul Szczepanek:

Quoted 13 lines · Thomas Monjalon
Quoted 10 lines

From: Paul Szczepanek <[email protected]>

To facilitate deploying docs to the website
and make paths more consistent remove the html directory from docs nested in API html directory.

---

Quoted 4 lines

Makes sense to remove the html from the css, thanks.

Won't the scripts complain about the order of tags? Signed off should come before reviewed.

Scripts are emitting warnings, and sometimes we can do differently :)

Here I prefer adding my Signoff at the end to show I did only last minute change.