All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH yocto-autobuilder-helper v16] Add a banner on the old documentation docs.
@ 2022-05-12 12:33 Abongwa Bonalais Amahnui
  2022-05-12 12:42 ` [yocto] " Quentin Schulz
  2022-05-12 14:00 ` [yocto] " richard.purdie
  0 siblings, 2 replies; 4+ messages in thread
From: Abongwa Bonalais Amahnui @ 2022-05-12 12:33 UTC (permalink / raw)
  To: yocto; +Cc: Abongwa Bonalais Amahnui

Script to add banners to the old docs and outdated dunfell docs

Signed-off-by: Abongwa Bonalais Amahnui <abongwabonalais@gmail.com>
---
 scripts/docs_add_banner.py | 84 ++++++++++++++++++++++++++++++++++++++
 scripts/run-docs-build     |  2 +
 2 files changed, 86 insertions(+)
 create mode 100755 scripts/docs_add_banner.py

diff --git a/scripts/docs_add_banner.py b/scripts/docs_add_banner.py
new file mode 100755
index 0000000..0de70d0
--- /dev/null
+++ b/scripts/docs_add_banner.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python3
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+#Signed-off-by: Abongwa Bonalais Amahnui <abongwabonalais@gmail.com>
+#
+#
+# Script to add banners to the old docs and outdated dunfell docs
+#
+#
+
+
+import os
+
+
+
+
+
+html_content_dunfell = '''
+<div id="outdated-warning">This document is outdated, you should select the <a href="https://docs.yoctoproject.org/dunfell">latest release version</a> in this series.</div>
+<div xml:lang="en" class="body" lang="en">
+'''
+html_content = '''
+<div id="outdated-warning">This version of the project is now considered obsolete, please select and use a <a href="https://docs.yoctoproject.org">more recent version</a>.</div>
+<div xml:lang="en" class="body" lang="en">
+'''
+
+# the class body and the last_div are used to make sure any .body property existing in any css file is not overwritten
+last_div = '''
+</div>
+
+'''
+
+css_replacement_content = '''
+ 
+  font-family: Verdana, Sans, sans-serif;
+
+  width: 100%;
+  margin:  0;
+  padding: 0;
+  color: #333;
+  overflow-x: hidden;
+  }
+ 
+.body{
+margin:  0 auto;
+min-width: 640px;
+padding: 0 5em 5em 5em;
+}
+#outdated-warning{
+text-align: center;
+background-color: rgb(255, 186, 186); 
+color: rgb(106, 14, 14); 
+padding: 0.5em 0; 
+width: 100%;
+position: fixed;
+top: 0;
+
+
+'''
+
+
+def add_banner_old_docs(dir):
+    for root, dirs, filenames in os.walk(dir):
+        
+        if root.startswith('./3.1'):
+            html_replacement = html_content_dunfell
+        else:
+            html_replacement = html_content
+            
+        for filename in filenames:
+            if filename.endswith('.html'):
+                with open(os.path.join(root, filename), 'r', encoding="ISO-8859-1") as f:
+                    current_content = f.read()
+                with open(os.path.join(root, filename), 'w', encoding="ISO-8859-1") as f:
+                    f.write(current_content.replace('<body>', '<body>' + html_replacement))
+                    f.write(current_content.replace('</body>', last_div + '</body>'))
+            if filename.endswith('.css'):
+                with open(os.path.join(root, filename), 'r', encoding="ISO-8859-1") as f:
+                    css_content = f.read()
+                with open(os.path.join(root, filename), 'w', encoding="ISO-8859-1") as f:
+                    f.write(css_content.replace(css_content[css_content.find('body {'):css_content.find('}'[0])], 'body {' + css_replacement_content ))
+
+add_banner_old_docs('.')
diff --git a/scripts/run-docs-build b/scripts/run-docs-build
index ecc5332..dce8f1f 100755
--- a/scripts/run-docs-build
+++ b/scripts/run-docs-build
@@ -37,6 +37,8 @@ cd $outputdir
 echo Extracing old content from archive
 tar -xJf $docbookarchive
 
+$scriptdir/docs_add_banner.py
+
 cd $bbdocs
 mkdir $outputdir/bitbake
 
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [yocto] [PATCH yocto-autobuilder-helper v16] Add a banner on the old documentation docs.
  2022-05-12 12:33 [PATCH yocto-autobuilder-helper v16] Add a banner on the old documentation docs Abongwa Bonalais Amahnui
@ 2022-05-12 12:42 ` Quentin Schulz
  2022-05-12 13:12   ` Abongwa Amahnui Bonalais
  2022-05-12 14:00 ` [yocto] " richard.purdie
  1 sibling, 1 reply; 4+ messages in thread
From: Quentin Schulz @ 2022-05-12 12:42 UTC (permalink / raw)
  To: Abongwa Amahnui Bonalais, yocto

Hi Amahnui,

On 5/12/22 14:33, Abongwa Amahnui Bonalais wrote:
> Script to add banners to the old docs and outdated dunfell docs
> 
> Signed-off-by: Abongwa Bonalais Amahnui <abongwabonalais@gmail.com>

Reviewed-by: Quentin Schulz <foss+yocto@0leil.net>

Thanks for the patch and your patience, this is an important piece that 
was missing, so thank you for taking the time to do it.

Now, other reviewers can still say that there are other changes to do.

If after a few weeks you still don't see your patch being merged in 
https://git.yoctoproject.org/yocto-autobuilder-helper, you can send a 
mail here telling us to have a look at it again, but that is usually 
unnecessary since merging is happening rather fast in this open-source 
project.

Cheers,
Quentin


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH yocto-autobuilder-helper v16] Add a banner on the old documentation docs.
  2022-05-12 12:42 ` [yocto] " Quentin Schulz
@ 2022-05-12 13:12   ` Abongwa Amahnui Bonalais
  0 siblings, 0 replies; 4+ messages in thread
From: Abongwa Amahnui Bonalais @ 2022-05-12 13:12 UTC (permalink / raw)
  To: yocto

[-- Attachment #1: Type: text/plain, Size: 992 bytes --]

On Thu, May 12, 2022 at 01:42 PM, Quentin Schulz wrote:

> 
> 
> On 5/12/22 14:33, Abongwa Amahnui Bonalais wrote:
> 
>> Script to add banners to the old docs and outdated dunfell docs
>> Signed-off-by: Abongwa Bonalais Amahnui <abongwabonalais@gmail.com>
> 
> Reviewed-by: Quentin Schulz <foss+yocto@0leil.net>
> 
> Thanks for the patch and your patience, this is an important piece that
> was missing, so thank you for taking the time to do it.
> 
> Now, other reviewers can still say that there are other changes to do.
> 
> If after a few weeks you still don't see your patch being merged in https://git.yoctoproject.org/yocto-autobuilder-helper
> , you can send a mail here telling us to have a look at it again, but that
> is usually unnecessary since merging is happening rather fast in this
> open-source project.
> 
> Cheers,
> Quentin

Hi Quentin,
Thank you very much too, I really appreciate your help through out this proccess, I will do as you've said.

[-- Attachment #2: Type: text/html, Size: 1154 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [yocto] [PATCH yocto-autobuilder-helper v16] Add a banner on the old documentation docs.
  2022-05-12 12:33 [PATCH yocto-autobuilder-helper v16] Add a banner on the old documentation docs Abongwa Bonalais Amahnui
  2022-05-12 12:42 ` [yocto] " Quentin Schulz
@ 2022-05-12 14:00 ` richard.purdie
  1 sibling, 0 replies; 4+ messages in thread
From: richard.purdie @ 2022-05-12 14:00 UTC (permalink / raw)
  To: Abongwa Amahnui Bonalais, yocto

On Thu, 2022-05-12 at 13:33 +0100, Abongwa Amahnui Bonalais wrote:
> Script to add banners to the old docs and outdated dunfell docs
> 
> Signed-off-by: Abongwa Bonalais Amahnui <abongwabonalais@gmail.com>
> ---
>  scripts/docs_add_banner.py | 84 ++++++++++++++++++++++++++++++++++++++
>  scripts/run-docs-build     |  2 +
>  2 files changed, 86 insertions(+)
>  create mode 100755 scripts/docs_add_banner.py
> 
> diff --git a/scripts/docs_add_banner.py b/scripts/docs_add_banner.py
> new file mode 100755
> index 0000000..0de70d0
> --- /dev/null
> +++ b/scripts/docs_add_banner.py
> @@ -0,0 +1,84 @@
> +#!/usr/bin/env python3
> +#
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +#Signed-off-by: Abongwa Bonalais Amahnui <abongwabonalais@gmail.com>
> +#
> +#
> +# Script to add banners to the old docs and outdated dunfell docs
> +#
> +#
> +
> +
> +import os
> +
> +
> +
> +
> +
> +html_content_dunfell = '''
> +<div id="outdated-warning">This document is outdated, you should select the <a href="https://docs.yoctoproject.org/dunfell">latest release version</a> in this series.</div>
> +<div xml:lang="en" class="body" lang="en">
> +'''
> +html_content = '''
> +<div id="outdated-warning">This version of the project is now considered obsolete, please select and use a <a href="https://docs.yoctoproject.org">more recent version</a>.</div>
> +<div xml:lang="en" class="body" lang="en">
> +'''
> +
> +# the class body and the last_div are used to make sure any .body property existing in any css file is not overwritten
> +last_div = '''
> +</div>
> +
> +'''
> +
> +css_replacement_content = '''
> + 
> +  font-family: Verdana, Sans, sans-serif;
> +
> +  width: 100%;
> +  margin:  0;
> +  padding: 0;
> +  color: #333;
> +  overflow-x: hidden;
> +  }
> + 
> +.body{
> +margin:  0 auto;
> +min-width: 640px;
> +padding: 0 5em 5em 5em;
> +}
> +#outdated-warning{
> +text-align: center;
> +background-color: rgb(255, 186, 186); 
> +color: rgb(106, 14, 14); 
> +padding: 0.5em 0; 
> +width: 100%;
> +position: fixed;
> +top: 0;
> +
> +
> +'''
> +
> +
> +def add_banner_old_docs(dir):
> +    for root, dirs, filenames in os.walk(dir):
> +        
> +        if root.startswith('./3.1'):
> +            html_replacement = html_content_dunfell
> +        else:
> +            html_replacement = html_content
> +            
> +        for filename in filenames:
> +            if filename.endswith('.html'):
> +                with open(os.path.join(root, filename), 'r', encoding="ISO-8859-1") as f:
> +                    current_content = f.read()
> +                with open(os.path.join(root, filename), 'w', encoding="ISO-8859-1") as f:
> +                    f.write(current_content.replace('<body>', '<body>' + html_replacement))
> +                    f.write(current_content.replace('</body>', last_div + '</body>'))


This is really close but still not quite right. You're adding in two
copies of current_content here. It needs to be:

 f.write(current_content.replace('<body>', '<body>' + html_replacement).replace('</body>', last_div + '</body>'))

so that only one copy of current_content is written.

Cheers,

Richard


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-12 14:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 12:33 [PATCH yocto-autobuilder-helper v16] Add a banner on the old documentation docs Abongwa Bonalais Amahnui
2022-05-12 12:42 ` [yocto] " Quentin Schulz
2022-05-12 13:12   ` Abongwa Amahnui Bonalais
2022-05-12 14:00 ` [yocto] " richard.purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.