Signed-off-by: Abongwa Bonalais Amahnui <[email protected]> --- scripts/docs_add_banner.py | 104 +++++++++++++++++++++++++++++++++++++ scripts/run-docs-build | 2 + 2 files changed, 106 insertions(+) create mode 100644 scripts/docs_add_banner.py
diff --git a/scripts/docs_add_banner.py b/scripts/docs_add_banner.py new file mode 100644 index 0000000..4b65664 --- /dev/null +++ b/scripts/docs_add_banner.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +# +# SPDX-License-Identifier: GPL-2.0-only +# +#Signed-off-by: Abongwa Bonalais Amahnui <[email protected]> +# +# +# 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): + exclude = [] + for root, dirs, filenames in os.walk(dir): + # exclude banner for 3.1.x upward as it is an LTS release and is still supported + exclude = [ name for name in os.listdir(dir) if name.startswith('3.1') ] + for d in dirs: + if d in exclude: + dirs.remove(d) + 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') as f: + f.write(current_content.replace('<body>', '<body>' + html_content)) + 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') 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('.') + + + + +def dunfell_docs(dir): + dunfell_banners = [] + for root, dirs, filenames in os.walk(dir): + dunfell_banners = [ name for name in os.listdir(dir) if not name.startswith('3.1') ] + for d in dirs: + if d in dunfell_banners: + dirs.remove(d) + 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') as f: + f.write(current_content.replace('<body>', '<body>' + html_content_dunfell)) + 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') as f: + f.write(css_content.replace(css_content[css_content.find('body {'):css_content.find('}'[0])], 'body {' + css_replacement_content )) +dunfell_docs('.') \ No newline at end of file diff --git a/scripts/run-docs-build b/scripts/run-docs-build index ecc5332..307ac19 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_fix_all_html_css.py + cd $bbdocs mkdir $outputdir/bitbake -- 2.25.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#56993): https://lists.yoctoproject.org/g/yocto/message/56993 Mute This Topic: https://lists.yoctoproject.org/mt/90884595/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
