diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2012-04-20 17:37:11 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2012-04-20 17:37:11 -0400 |
commit | 78e2c8c6e014b205e5f2cf7764ca9cf3597b318a (patch) | |
tree | 99dcb9b259c8c343e1623c705dda50201b7b0d82 /coverage/html.py | |
parent | 886c61c219b68dd66103a8c05f96ae9bf6b82ad6 (diff) | |
download | python-coveragepy-git-78e2c8c6e014b205e5f2cf7764ca9cf3597b318a.tar.gz |
The [html]extra_css configuration value is a file path to a CSS file that gets copied into the HTML report.
Diffstat (limited to 'coverage/html.py')
-rw-r--r-- | coverage/html.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/coverage/html.py b/coverage/html.py index af27edfa..f39bf949 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -58,6 +58,7 @@ class HtmlReporter(Reporter): self.files = [] self.arcs = self.coverage.data.has_arcs() self.status = HtmlStatus() + self.extra_css = None def report(self, morfs): """Generate an HTML report for `morfs`. @@ -78,6 +79,10 @@ class HtmlReporter(Reporter): self.status.reset() self.status.set_settings_hash(these_settings) + # The user may have extra CSS they want copied. + if self.config.extra_css: + self.extra_css = os.path.basename(self.config.extra_css) + # Process all the files. self.report_files(self.html_file, morfs, self.config.html_dir) @@ -91,12 +96,20 @@ class HtmlReporter(Reporter): def make_local_static_report_files(self): """Make local instances of static files for HTML report.""" + # The files we provide must always be copied. for static in self.STATIC_FILES: shutil.copyfile( data_filename("htmlfiles/" + static), os.path.join(self.directory, static) ) + # The user may have extra CSS they want copied. + if self.extra_css: + shutil.copyfile( + self.config.extra_css, + os.path.join(self.directory, self.extra_css) + ) + def write_html(self, fname, html): """Write `html` to `fname`, properly encoded.""" fout = open(fname, "wb") @@ -202,6 +215,7 @@ class HtmlReporter(Reporter): # Write the HTML page for this file. html_filename = flat_rootname + ".html" html_path = os.path.join(self.directory, html_filename) + extra_css = self.extra_css html = spaceless(self.source_tmpl.render(locals())) if sys.version_info < (3, 0): @@ -228,6 +242,7 @@ class HtmlReporter(Reporter): arcs = self.arcs totals = sum([f['nums'] for f in files]) + extra_css = self.extra_css self.write_html( os.path.join(self.directory, "index.html"), |