Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding css files code to the LOBSTER HTML report #156

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lobster/html/htmldoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def __init__(self, title, subtitle):
}
self.scripts = []
self.body = []
self.css_files = []
self.css = []

def add_line(self, line):
assert isinstance(line, str)
Expand Down Expand Up @@ -293,11 +293,11 @@ def render(self):
for attr, value in style.items():
rv.append(" %s: %s;" % (attr, value))
rv.append("}")
rv.append("</style>")

# add css files that are appended to self.files
for css_file in self.css_files:
rv.append(f"<link rel='stylesheet' href={css_file}>")
for css_file in self.css:
rv.append(css_file)
rv.append("</style>")
rv.append("</head>")
rv.append("<body>")

Expand Down
17 changes: 12 additions & 5 deletions lobster/tools/core/html_report/html_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,21 @@ def write_html(fd, report, dot, high_contrast):

# Add the css from assets
dir_path = os.path.dirname(os.path.abspath(__file__))
file_path = dir_path + "/assets/html_report.css"
doc.css_files.append(file_path)
file_path = dir_path + "/assets"
for filename in os.listdir(file_path):
if filename.endswith(".css"):
filename = os.path.join(file_path, filename)
with open(filename, "r", encoding="UTF-8") as styles:
doc.css.append("".join(styles.readlines()))

# Add javascript from assets/html_report.js file
dir_path = os.path.dirname(os.path.abspath(__file__))
file_path = dir_path + "/assets/html_report.js"
with open(file_path, "r", encoding="UTF-8") as scripts:
doc.scripts.append("".join(scripts.readlines()))
file_path = dir_path + "/assets"
for filename in os.listdir(file_path):
if filename.endswith(".js"):
filename = os.path.join(file_path, filename)
with open(filename, "r", encoding="UTF-8") as scripts:
doc.scripts.append("".join(scripts.readlines()))

### STM
# doc.add_heading(2, "Software traceability matrix", "matrix")
Expand Down
Loading