mirror of
git://git.yoctoproject.org/yocto-autobuilder-helper.git
synced 2025-07-19 20:59:02 +02:00
scripts/docs_add_banner: Fix several issues
* Fix a syntax error causing the script to fail * Skip symlinks files (symlink directories were already skipped) * Drop unneeded whitespace * Abstract path join to a variable Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
5dd90ea43b
commit
9d7820da27
|
@ -9,13 +9,8 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
html_content_dunfell = '''
|
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 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">
|
<div xml:lang="en" class="body" lang="en">
|
||||||
|
@ -32,7 +27,7 @@ last_div = '''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
css_replacement_content = '''
|
css_replacement_content = '''
|
||||||
|
|
||||||
font-family: Verdana, Sans, sans-serif;
|
font-family: Verdana, Sans, sans-serif;
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -41,7 +36,7 @@ css_replacement_content = '''
|
||||||
color: #333;
|
color: #333;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.body{
|
.body{
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
min-width: 640px;
|
min-width: 640px;
|
||||||
|
@ -49,9 +44,9 @@ padding: 0 5em 5em 5em;
|
||||||
}
|
}
|
||||||
#outdated-warning{
|
#outdated-warning{
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background-color: rgb(255, 186, 186);
|
background-color: rgb(255, 186, 186);
|
||||||
color: rgb(106, 14, 14);
|
color: rgb(106, 14, 14);
|
||||||
padding: 0.5em 0;
|
padding: 0.5em 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
@ -62,22 +57,25 @@ top: 0;
|
||||||
|
|
||||||
def add_banner_old_docs(dir):
|
def add_banner_old_docs(dir):
|
||||||
for root, dirs, filenames in os.walk(dir):
|
for root, dirs, filenames in os.walk(dir):
|
||||||
|
|
||||||
if root.startswith('./3.1'):
|
if root.startswith('./3.1'):
|
||||||
html_replacement = html_content_dunfell
|
html_replacement = html_content_dunfell
|
||||||
else:
|
else:
|
||||||
html_replacement = html_content
|
html_replacement = html_content
|
||||||
|
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
|
fullfile = os.path.join(root, filename)
|
||||||
|
if os.path.islink(fullfile):
|
||||||
|
continue
|
||||||
if filename.endswith('.html'):
|
if filename.endswith('.html'):
|
||||||
with open(os.path.join(root, filename), 'r', encoding="ISO-8859-1") as f:
|
with open(fullfile, 'r', encoding="ISO-8859-1") as f:
|
||||||
current_content = f.read()
|
current_content = f.read()
|
||||||
with open(os.path.join(root, filename), 'w', encoding="ISO-8859-1") as f:
|
with open(fullfile, 'w', encoding="ISO-8859-1") as f:
|
||||||
f.write(current_content.replace('<body>', '<body>' + html_replacement)).replace('</body>', last_div + '</body>'))
|
f.write(current_content.replace('<body>', '<body>' + html_replacement).replace('</body>', last_div + '</body>'))
|
||||||
if filename.endswith('.css'):
|
elif filename.endswith('.css'):
|
||||||
with open(os.path.join(root, filename), 'r', encoding="ISO-8859-1") as f:
|
with open(fullfile, 'r', encoding="ISO-8859-1") as f:
|
||||||
css_content = f.read()
|
css_content = f.read()
|
||||||
with open(os.path.join(root, filename), 'w', encoding="ISO-8859-1") as f:
|
with open(fullfile, '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 ))
|
f.write(css_content.replace(css_content[css_content.find('body {'):css_content.find('}'[0])], 'body {' + css_replacement_content ))
|
||||||
|
|
||||||
add_banner_old_docs('.')
|
add_banner_old_docs('.')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user