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

Local CSS #540

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ This will make a directory named `html` in your root directory (unless `--output

By default, the generated HTML will reference locally hosted assets (js, css). You can specify the `--cdn-assets` to specify that you prefer for the generated HTML to use externally hosted assets. This can be useful if publishing the HTML file as a build artifact.

By default, the generated HTML will reference an external CSS source. However, on Azure Pipelines, external links are blocked, resulting in the absence of any CSS styling. To work around this, you can use the '--local-css' option. This tells the generator to use local CSS contained within a style tag, as opposed to referencing remote CSS via a link.

### TeamCity Reporting

To report the coverage statistics to TeamCity:
Expand Down
2 changes: 2 additions & 0 deletions lib/slather/command/coverage_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CoverageCommand < Clamp::Command
option ["--html"], :flag, "Output coverage results as static html pages"
option ["--show"], :flag, "Indicate that the static html pages will open automatically"
option ["--cdn-assets"], :flag, "Indicate that the static html pages will load assets from a CDN"
option ["--local-css"], :flag, "Indicate that the static html pages will have local css"

option ["--build-directory", "-b"], "BUILD_DIRECTORY", "The directory where gcno files will be written to. Defaults to derived data."
option ["--source-directory"], "SOURCE_DIRECTORY", "The directory where your source files are located."
Expand Down Expand Up @@ -128,6 +129,7 @@ def setup_coverage_service
project.coverage_service = :html
project.show_html = show?
project.cdn_assets = cdn_assets?
project.local_css = local_css?
elsif json?
project.coverage_service = :json
elsif sonarqube_xml?
Expand Down
3 changes: 3 additions & 0 deletions lib/slather/coverage_service/html_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ def generate_html_template(title, is_index, is_file_empty)
doc.head {
doc.title "#{title} - Slather"
doc.link :href => css_path, :media => "all", :rel => "stylesheet"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If local_css is enabled should doc.link be skipped?

if local_css
doc.style "/* General */html { position: relative; min-height: 100%;}body { font: 16px \”Helvetica\”, sans-serif; margin: 0 0 120px; color: #333;}.row { margin: 0 2em; }/* Header */header { margin-top: 1em; }header img { width: auto; height: 120px; }/* Coverage */#reports > h2 { margin-bottom: 0; }#reports > h4 { margin-top: 5px; }.percentage { padding: 4px ; font-weight: bold;}.cov_high { color: #67CF7C; }.cov_medium { color: #F89404; }.cov_low { color: #F86769; }.cov_title { margin-bottom: 0; }.cov_subtitle { margin-top: 0.2em; }.cov_filepath { font-style: italic; }/* Index Table */table.coverage_list { width: 90%; min-width: 400px;}table.coverage_list th,table.coverage_list td { padding: .6em .5em; text-align: left;}table.coverage_list th.col_num { width: 70px; }table.coverage_list th.col_percent { width: 75px; }table.coverage_list thead, tfoot { background: #FDCD9B; }table.coverage_list tbody tr:hover { background: #FCF2E6; }table.coverage_list tbody td { border-bottom: 1px solid #CCC; }table.coverage_list td a { color: #333; text-decoration: none; border-bottom: 1px dotted;}table.coverage_list td a:hover { border-bottom: none;}/* Source Code */table.source_code { width: 100%; max-width: 1200px; min-width: 400px; font-size: 13px; border-spacing: 0; background: #FCF2E6; padding: 1.2em 1em; margin-bottom: 2em;}table.source_code td { padding-bottom: 0.3em;}code.missed { background-color: rgba(255, 73, 76, 0.3); }table.source_code tr.missed td { background-color: rgba(248, 103, 105, 0.2); }table.source_code tr.covered td { background-color: rgba(103, 207, 124, 0.2); }table.source_code td.num { border-right: 1px rgba(0,0,0,0.1) solid; text-align: right; padding-right: 1em; width: 30px;}table.source_code td.src { border-left: 1px rgba(255,255,255,0.7) solid; padding-left: 1em;}table.source_code td.src pre { white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word; margin: 0;}table.source_code td.src pre code { font: 13px \”Menlo\”, \”Courier New\”; }table.source_code td.coverage { text-align: right; padding-right: 0.5em;}/* Footer */footer { background-color: #67CDCF; height: 80px; position: absolute; left: 0; bottom: 0; width: 100%; overflow:hidden;}footer p, footer a { color: #ffffff; font-weight: bold; text-align: center;}/* ----------------------------------------------------------Syntax Highlighting using highlight.js (https://highlightjs.org)------------------------------------------------------------- */.hljs { display: inline-block; overflow-x: auto; -webkit-text-size-adjust: none;}.hljs,.hljs-subst,.hljs-tag .hljs-title,.nginx .hljs-title { color: #333;}.hljs-string,.hljs-title,.hljs-constant,.hljs-parent,.hljs-tag .hljs-value,.hljs-rule .hljs-value,.hljs-preprocessor,.hljs-pragma,.hljs-name,.haml .hljs-symbol,.ruby .hljs-symbol,.ruby .hljs-symbol .hljs-string,.hljs-template_tag,.django .hljs-variable,.smalltalk .hljs-class,.hljs-addition,.hljs-flow,.hljs-stream,.bash .hljs-variable,.pf .hljs-variable,.apache .hljs-tag,.apache .hljs-cbracket,.tex .hljs-command,.tex .hljs-special,.erlang_repl .hljs-function_or_atom,.asciidoc .hljs-header,.markdown .hljs-header,.coffeescript .hljs-attribute,.tp .hljs-variable { color: #D14F4F;}.smartquote,.hljs-comment,.hljs-annotation,.diff .hljs-header,.hljs-chunk,.asciidoc .hljs-blockquote,.markdown .hljs-blockquote { color: #888;}.hljs-number,.hljs-date,.hljs-regexp,.hljs-literal,.hljs-hexcolor,.smalltalk .hljs-symbol,.smalltalk .hljs-char,.go .hljs-constant,.hljs-change,.lasso .hljs-variable,.makefile .hljs-variable,.asciidoc .hljs-bullet,.markdown .hljs-bullet,.asciidoc .hljs-link_url,.markdown .hljs-link_url { color: #05A5A8;}.hljs-label,.ruby .hljs-string,.hljs-decorator,.hljs-filter .hljs-argument,.hljs-localvars,.hljs-array,.hljs-attr_selector,.hljs-important,.hljs-pseudo,.hljs-pi,.haml .hljs-bullet,.hljs-doctype,.hljs-deletion,.hljs-envvar,.hljs-shebang,.apache .hljs-sqbracket,.nginx .hljs-built_in,.tex .hljs-formula,.erlang_repl .hljs-reserved,.hljs-prompt,.asciidoc .hljs-link_label,.markdown .hljs-link_label,.vhdl .hljs-attribute,.clojure .hljs-attribute,.asciidoc .hljs-attribute,.lasso .hljs-attribute,.coffeescript .hljs-property,.hljs-phony { color: #087599;}.hljs-keyword,.hljs-id,.hljs-title,.hljs-built_in,.css .hljs-tag,.hljs-doctag,.smalltalk .hljs-class,.hljs-winutils,.bash .hljs-variable,.pf .hljs-variable,.apache .hljs-tag,.hljs-type,.hljs-typename,.tex .hljs-command,.asciidoc .hljs-strong,.markdown .hljs-strong,.hljs-request,.hljs-status,.tp .hljs-data,.tp .hljs-io { font-weight: bold;}.asciidoc .hljs-emphasis,.markdown .hljs-emphasis,.tp .hljs-units { font-style: italic;}.nginx .hljs-built_in { font-weight: normal;}.coffeescript .javascript,.javascript .xml,.lasso .markup,.tex .hljs-formula,.xml .javascript,.xml .vbscript,.xml .css,.xml .hljs-cdata { opacity: 0.5;}/* -------------------------------------------------------Sorting & Filtering with List.js (http://www.listjs.com/)------------------------------------------------------- */input.search { border:solid 1px #ccc; border-radius: 4px; padding:7px; margin-bottom:10px; font-size: 12px;}input.search:focus { outline:none; border-color:#aaa;}th.sort::-moz-selection { background:transparent; }th.sort::selection { background:transparent; }th.sort { cursor:pointer; }th.sort:after { content:''; display:inline-block; width: 0; height: 0; position: relative; top: -3px; right: -6px; border-width:0 4px 4px; border-style:solid; border-color:#404040 transparent; visibility:hidden;} th.sort:hover:after { visibility:visible; } th.sort.desc:after, th.sort.asc:after, th.sort.asc:hover:after { visibility:visible; opacity:0.6;} th.sort.desc:after { border-bottom:none; border-width:4px 4px 0;}"
end
}
doc.body {
doc.header {
Expand Down
2 changes: 1 addition & 1 deletion lib/slather/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module Slather
class Project < Xcodeproj::Project

attr_accessor :build_directory, :ignore_list, :ci_service, :coverage_service, :coverage_access_token, :source_directory,
:output_directory, :xcodeproj, :show_html, :cdn_assets, :verbose_mode, :input_format, :scheme, :workspace, :binary_file, :binary_basename, :arch, :source_files,
:output_directory, :xcodeproj, :show_html, :cdn_assets, :local_css, :verbose_mode, :input_format, :scheme, :workspace, :binary_file, :binary_basename, :arch, :source_files,
:decimals, :llvm_version, :configuration

alias_method :setup_for_coverage, :slather_setup_for_coverage
Expand Down