From 38677268d441ae5ec444f2383f68e14532bf2d3d Mon Sep 17 00:00:00 2001 From: Tyler Reddy Date: Sat, 1 Jun 2019 16:24:54 -0700 Subject: [PATCH] ENH: add docstring cov to html * provide a config file option that allows docstrings probed by doctest to be highlighted in html reports --- coverage/config.py | 2 ++ coverage/html.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/coverage/config.py b/coverage/config.py index 30f46e589..7c8c1e0c1 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -206,6 +206,7 @@ def __init__(self): self.extra_css = None self.html_dir = "htmlcov" self.html_title = "Coverage report" + self.html_docstr = False # Defaults for [xml] self.xml_output = "coverage.xml" @@ -353,6 +354,7 @@ def from_file(self, filename, our_file): ('extra_css', 'html:extra_css'), ('html_dir', 'html:directory'), ('html_title', 'html:title'), + ('html_docstr', 'html:docstring_display'), # [xml] ('xml_output', 'xml:output'), diff --git a/coverage/html.py b/coverage/html.py index d5edd5f7a..c411dcffd 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -252,6 +252,13 @@ def html_file(self, fr, analysis): ) elif lineno in analysis.statements: line_class.append(c_run) + elif self.config.html_docstr: + # count docstring line as "executed" + # doctest SKIP directives will not + # prevent a line from being marked + # as executed, but will influence + # the associated source code proper + line_class.append(c_run) # Build the HTML for the line. html = []