Skip to contentSkip to conversation

custom doc styling

PATCH Superseded Thomas Monjalon 2 participants 17 messages Jul 21, 2024 – Jul 31, 2024 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover custom doc styling

The file custom.css allows to change the theme from "Read the Docs". The first patch makes it available without "ninja install". The second patch allows the NIC overview tables to be "fullscreen".

Thomas Monjalon (2):
doc: copy custom CSS on guides build
doc: give full width to NIC overview page

 buildtools/call-sphinx-build.py | 9 +++++++++
 doc/guides/custom.css           | 8 ++++++++
 doc/guides/meson.build          | 2 --
 doc/guides/nics/overview.rst    | 2 ++
 4 files changed, 19 insertions(+), 2 deletions(-)
Signature · 1 line
2.45.0
#1 lore raw

PATCH 1/2 doc: copy custom CSS on guides build

The custom CSS file for Sphinx guides was copied during install, but not during build time.
Before switching to Meson, the Makefile was copying this file in the build steps, so the doc was complete and viewable from the build directory.

It is especially useful to get full documentation in the build directory when building only documentation with "ninja -C build doc". The command "ninja install" was required to get the CSS file installed, but it requires to build the libraries as well.

The CSS file is now copied as part of the Sphinx build script, and it will be installed as part of the whole html directory.

---
 buildtools/call-sphinx-build.py | 9 +++++++++
 doc/guides/meson.build          | 2 --
 2 files changed, 9 insertions(+), 2 deletions(-)
buildtools/call-sphinx-build.py +9 -0
index da19e950c9..99e396bdd7 100755
@@ -3,6 +3,8 @@
 # Copyright(c) 2019 Intel Corporation
 #
 
+import filecmp
+import shutil
 import sys
 import os
 from os.path import join
@@ -30,4 +32,11 @@
 with open(join(dst, '.html.d'), 'w') as d:
     d.write('html: ' + ' '.join(srcfiles) + '\n')
 
+# copy custom CSS file
+css = 'custom.css'
+src_css = join(src, css)
+dst_css = join(dst, 'html', '_static', 'css', css)
+if not os.path.exists(dst_css) or not filecmp.cmp(src_css, dst_css):
+    shutil.copyfile(src_css, dst_css)
+
 sys.exit(process.returncode)
doc/guides/meson.build +0 -2
index 51f81da2e3..f8bbfba9f5 100644
@@ -24,7 +24,5 @@ html_guides = custom_target('html_guides',
         install: get_option('enable_docs'),
         install_dir: htmldir)
 
-install_data(files('custom.css'), install_dir: join_paths(htmldir,'_static', 'css'))
-
 doc_targets += html_guides
 doc_target_names += 'HTML_Guides'
Signature · 1 line
2.45.0
#2 lore raw

PATCH 2/2 doc: give full width to NIC overview page

In reply to Thomas Monjalon

The wide tables in the NIC overview exceed the normal page width because of the large number of drivers.

A CSS trick is added to allow displaying this page in the full width of the browser window.

---
 doc/guides/custom.css        | 8 ++++++++
 doc/guides/nics/overview.rst | 2 ++
 2 files changed, 10 insertions(+)
doc/guides/custom.css +8 -0
index 221024655c..df1a52f1d4 100644
@@ -4,6 +4,14 @@
 
 /* Override readthedocs theme */
 
+/* Set full width on a page.
+ * Usage: insert the following line in the doc.
+ *        .. rst-class:: widepage
+ */
+.wy-nav-content:has(.widepage) {
+    max-width: none !important;
+}
+
 /* Spacing before a list item must be bigger than spacing inside the item.
  * Complex list items start with a p.first element. */
 .section li > .first {
doc/guides/nics/overview.rst +2 -0
index 67575c699c..4553076481 100644
@@ -24,6 +24,8 @@ Most of these differences are summarized below.
 
 More details about features can be found in :doc:`features`.
 
+.. rst-class:: widepage
+
 .. _table_net_pmd_features:
 
 .. include:: overview_table.txt
Signature · 1 line
2.45.0
#3 lore raw

v2 cover custom doc styling

In reply to Thomas Monjalon

The file custom.css allows to change the theme from "Read the Docs". The first patch makes it available without "ninja install". The second patch allows the NIC overview tables to be "fullscreen".

Thomas Monjalon (2):
doc: copy custom CSS on guides build
doc: give full width to NIC overview page

 buildtools/call-sphinx-build.py | 10 ++++++++++
 doc/guides/custom.css           |  8 ++++++++
 doc/guides/meson.build          |  2 --
 doc/guides/nics/overview.rst    |  2 ++
 4 files changed, 20 insertions(+), 2 deletions(-)
Signature · 1 line
2.45.0
#4 lore raw

PATCH v2 1/2 doc: copy custom CSS on guides build

The custom CSS file for Sphinx guides was copied during install, but not during build time.
Before switching to Meson, the Makefile was copying this file in the build steps, so the doc was complete and viewable from the build directory.

It is especially useful to get full documentation in the build directory when building only documentation with "ninja -C build doc". The command "ninja install" was required to get the CSS file installed, but it requires to build the libraries as well.

The CSS file is now copied as part of the Sphinx build script, and it will be installed as part of the whole html directory.

---
v2: create destination directory in case RtD theme is unavailable

---
 buildtools/call-sphinx-build.py | 10 ++++++++++
 doc/guides/meson.build          |  2 --
 2 files changed, 10 insertions(+), 2 deletions(-)
buildtools/call-sphinx-build.py +10 -0
index da19e950c9..623e7363ee 100755
@@ -3,6 +3,8 @@
 # Copyright(c) 2019 Intel Corporation
 #
 
+import filecmp
+import shutil
 import sys
 import os
 from os.path import join
@@ -30,4 +32,12 @@
 with open(join(dst, '.html.d'), 'w') as d:
     d.write('html: ' + ' '.join(srcfiles) + '\n')
 
+# copy custom CSS file
+css = 'custom.css'
+src_css = join(src, css)
+dst_css = join(dst, 'html', '_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)
+
 sys.exit(process.returncode)
doc/guides/meson.build +0 -2
index 51f81da2e3..f8bbfba9f5 100644
@@ -24,7 +24,5 @@ html_guides = custom_target('html_guides',
         install: get_option('enable_docs'),
         install_dir: htmldir)
 
-install_data(files('custom.css'), install_dir: join_paths(htmldir,'_static', 'css'))
-
 doc_targets += html_guides
 doc_target_names += 'HTML_Guides'
Signature · 1 line
2.45.0
Acked-by Tested-by on v2 1/2
#5 lore raw

Re: [PATCH v2 1/2] doc: copy custom CSS on guides build

Quoted 11 lines · Thomas Monjalon

The custom CSS file for Sphinx guides was copied during install, but not during build time.
Before switching to Meson, the Makefile was copying this file in the build steps, so the doc was complete and viewable from the build directory.

It is especially useful to get full documentation in the build directory when building only documentation with "ninja -C build doc". The command "ninja install" was required to get the CSS file installed, but it requires to build the libraries as well.

Quoted 5 lines

The CSS file is now copied as part of the Sphinx build script, and it will be installed as part of the whole html directory.

#6 lore raw

PATCH v2 2/2 doc: give full width to NIC overview page

In reply to Thomas Monjalon

The wide tables in the NIC overview exceed the normal page width because of the large number of drivers.

A CSS trick is added to allow displaying this page in the full width of the browser window.

---
v2: no change

---
 doc/guides/custom.css        | 8 ++++++++
 doc/guides/nics/overview.rst | 2 ++
 2 files changed, 10 insertions(+)
doc/guides/custom.css +8 -0
index 221024655c..df1a52f1d4 100644
@@ -4,6 +4,14 @@
 
 /* Override readthedocs theme */
 
+/* Set full width on a page.
+ * Usage: insert the following line in the doc.
+ *        .. rst-class:: widepage
+ */
+.wy-nav-content:has(.widepage) {
+    max-width: none !important;
+}
+
 /* Spacing before a list item must be bigger than spacing inside the item.
  * Complex list items start with a p.first element. */
 .section li > .first {
doc/guides/nics/overview.rst +2 -0
index 67575c699c..4553076481 100644
@@ -24,6 +24,8 @@ Most of these differences are summarized below.
 
 More details about features can be found in :doc:`features`.
 
+.. rst-class:: widepage
+
 .. _table_net_pmd_features:
 
 .. include:: overview_table.txt
Signature · 1 line
2.45.0
#7 lore raw

Re: [PATCH v2 2/2] doc: give full width to NIC overview page

Quoted 8 lines · Thomas Monjalon

The wide tables in the NIC overview exceed the normal page width because of the large number of drivers.

A CSS trick is added to allow displaying this page in the full width of the browser window.

This makes the feature table wider, so all table can fit, and scroll bar below the table is gone, this is good.

But also it makes all paragraphs and 'Note' boxes in that page fill all the screen, and with a wide screen this becomes a long box through end of the screen and personally I think doesn't look nice.

Instead of making it full screen, is there are way to make it fixed size, but larger than previous so that table still can expand fully?

#8 lore raw

Re: [PATCH v2 2/2] doc: give full width to NIC overview page

31/07/2024 13:29, Ferruh Yigit:

Quoted 13 lines · Thomas Monjalon
Quoted 8 lines

The wide tables in the NIC overview exceed the normal page width because of the large number of drivers.

A CSS trick is added to allow displaying this page in the full width of the browser window.

This makes the feature table wider, so all table can fit, and scroll bar below the table is gone, this is good.

Quoted 6 lines

But also it makes all paragraphs and 'Note' boxes in that page fill all the screen, and with a wide screen this becomes a long box through end of the screen and personally I think doesn't look nice.

Instead of making it full screen, is there are way to make it fixed size, but larger than previous so that table still can expand fully?

We may try to restrict non-table containers, but then it will be less generic. I mean this solution could apply to any large page today.

We may try to force the width of <p> and <ul>.

#9 lore raw

Re: [PATCH v2 2/2] doc: give full width to NIC overview page

31/07/2024 14:43, Thomas Monjalon:

Quoted 18 lines

31/07/2024 13:29, Ferruh Yigit:

Quoted 17 lines · Thomas Monjalon
Quoted 8 lines

The wide tables in the NIC overview exceed the normal page width because of the large number of drivers.

A CSS trick is added to allow displaying this page in the full width of the browser window.

This makes the feature table wider, so all table can fit, and scroll bar below the table is gone, this is good.

But also it makes all paragraphs and 'Note' boxes in that page fill all the screen, and with a wide screen this becomes a long box through end of the screen and personally I think doesn't look nice.

Quoted 7 lines
Quoted 2 lines

Instead of making it full screen, is there are way to make it fixed size, but larger than previous so that table still can expand fully?

We may try to restrict non-table containers, but then it will be less generic. I mean this solution could apply to any large page today.

We may try to force the width of <p> and <ul>.

I've found another trick to let only tables overflow. I'll send a v3 and will apply quickly.

#10 lore raw

v3 cover custom doc styling

In reply to Thomas Monjalon

The file custom.css allows to change the theme from "Read the Docs". The first patch makes it available without "ninja install". The second patch allows the NIC overview tables to be "fullscreen".

Thomas Monjalon (2):
doc: copy custom CSS on guides build
doc: give full width to NIC overview page

 buildtools/call-sphinx-build.py | 10 ++++++++++
 doc/guides/custom.css           | 13 +++++++++++++
 doc/guides/meson.build          |  2 --
 doc/guides/nics/overview.rst    |  2 ++
 4 files changed, 25 insertions(+), 2 deletions(-)
Signature · 1 line
2.45.0
#11 lore raw

PATCH v3 1/2 doc: copy custom CSS on guides build

The custom CSS file for Sphinx guides was copied during install, but not during build time.
Before switching to Meson, the Makefile was copying this file in the build steps, so the doc was complete and viewable from the build directory.

It is especially useful to get full documentation in the build directory when building only documentation with "ninja -C build doc". The command "ninja install" was required to get the CSS file installed, but it requires to build the libraries as well.

The CSS file is now copied as part of the Sphinx build script, and it will be installed as part of the whole html directory.

---
v2: create destination directory in case RtD theme is unavailable
v3: no change

---
 buildtools/call-sphinx-build.py | 10 ++++++++++
 doc/guides/meson.build          |  2 --
 2 files changed, 10 insertions(+), 2 deletions(-)
buildtools/call-sphinx-build.py +10 -0
index da19e950c9..623e7363ee 100755
@@ -3,6 +3,8 @@
 # Copyright(c) 2019 Intel Corporation
 #
 
+import filecmp
+import shutil
 import sys
 import os
 from os.path import join
@@ -30,4 +32,12 @@
 with open(join(dst, '.html.d'), 'w') as d:
     d.write('html: ' + ' '.join(srcfiles) + '\n')
 
+# copy custom CSS file
+css = 'custom.css'
+src_css = join(src, css)
+dst_css = join(dst, 'html', '_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)
+
 sys.exit(process.returncode)
doc/guides/meson.build +0 -2
index 51f81da2e3..f8bbfba9f5 100644
@@ -24,7 +24,5 @@ html_guides = custom_target('html_guides',
         install: get_option('enable_docs'),
         install_dir: htmldir)
 
-install_data(files('custom.css'), install_dir: join_paths(htmldir,'_static', 'css'))
-
 doc_targets += html_guides
 doc_target_names += 'HTML_Guides'
Signature · 1 line
2.45.0
#12 lore raw

PATCH v3 2/2 doc: give full width to NIC overview page

In reply to Thomas Monjalon

The wide tables in the NIC overview exceed the normal page width because of the large number of drivers.

A CSS trick is added to allow displaying the tables in the full width of the browser window.

---
v2: no change
v3: let only tables to overflow on wide screen

---
 doc/guides/custom.css        | 13 +++++++++++++
 doc/guides/nics/overview.rst |  2 ++
 2 files changed, 15 insertions(+)
doc/guides/custom.css +13 -0
index 221024655c..a8ee6bed2c 100644
@@ -4,6 +4,19 @@
 
 /* Override readthedocs theme */
 
+/* Set full width for all responsive tables of a page.
+ * Usage: insert the following line in the doc.
+ *        .. rst-class:: widepage
+ */
+@media screen and (min-width: 1100px) {
+    .wy-nav-content-wrap:has(.widepage) {
+        background: white !important;
+    }
+    .wy-nav-content:has(.widepage) .wy-table-responsive {
+        overflow: visible !important;
+    }
+}
+
 /* Spacing before a list item must be bigger than spacing inside the item.
  * Complex list items start with a p.first element. */
 .section li > .first {
doc/guides/nics/overview.rst +2 -0
index 67575c699c..4553076481 100644
@@ -24,6 +24,8 @@ Most of these differences are summarized below.
 
 More details about features can be found in :doc:`features`.
 
+.. rst-class:: widepage
+
 .. _table_net_pmd_features:
 
 .. include:: overview_table.txt
Signature · 1 line
2.45.0
#13 lore raw

Re: [PATCH v3 2/2] doc: give full width to NIC overview page

Quoted 11 lines · Thomas Monjalon

The wide tables in the NIC overview exceed the normal page width because of the large number of drivers.

A CSS trick is added to allow displaying the tables in the full width of the browser window.

---
v2: no change
v3: let only tables to overflow on wide screen

It is better, thanks. Now page boundaries are kept but table extended to fit all columns.

You are improving front-end skills :)

Only color of the overview page is not white as it is in other pages, but slight gray, is this intentional?

#14 lore raw

Re: [PATCH v3 2/2] doc: give full width to NIC overview page

31/07/2024 18:17, Ferruh Yigit:

Quoted 13 lines · Thomas Monjalon
Quoted 11 lines

The wide tables in the NIC overview exceed the normal page width because of the large number of drivers.

A CSS trick is added to allow displaying the tables in the full width of the browser window.

---
v2: no change
v3: let only tables to overflow on wide screen

Quoted 4 lines

It is better, thanks. Now page boundaries are kept but table extended to fit all columns.

You are improving front-end skills :)

Thanks, that's a fun skill to work on :)

Quoted 2 lines

Only color of the overview page is not white as it is in other pages, but slight gray, is this intentional?

It seems all pages are not really white, but #fcfcfc. I'll apply the same color for the whole background of the tables.

#15 lore raw
In reply to Thomas Monjalon

31/07/2024 17:57, Thomas Monjalon:

Quoted 7 lines

The file custom.css allows to change the theme from "Read the Docs". The first patch makes it available without "ninja install". The second patch allows the NIC overview tables to be "fullscreen".

Thomas Monjalon (2):
doc: copy custom CSS on guides build
doc: give full width to NIC overview page

Applied with background color fixed.

Acked-by
#16 lore raw
Quoted 11 lines · Thomas Monjalon

31/07/2024 17:57, Thomas Monjalon:

Quoted 7 lines

The file custom.css allows to change the theme from "Read the Docs". The first patch makes it available without "ninja install". The second patch allows the NIC overview tables to be "fullscreen".

Thomas Monjalon (2):
doc: copy custom CSS on guides build
doc: give full width to NIC overview page

Applied with background color fixed.

You already applied, but let me give my explicit ack for record: