Skip to content

Colour lines of HTML report, to make it easier to see parentage #5

Open

Description

@OsePedro

When viewing deep callstacks, it's hard to see which call sites share a caller of interest. It would be clearer if the lines were coloured, as in this mockup, where the colours make it immediately clear that runParserWithModeComments calls mparseExp and ngparseModulePragmas:

ColourfulProfiterole

If I'm not mistaken, the simplest clean way to do this would be to replace:

  1. (showHTML links . rootLabel) with (showHTML links . (0,) . rootLabel) (if you don't mind adding the TupleSections extension);
  2. fmapTreeDepth indent x with fmapTreeDepth (,) x.

Then showHTML can be replaced with

showHTML :: Set.Set String -> (Int, Val) -> String
showHTML xs (indent, Val{..}) = 
    (col $ intercalate "  " [showDouble timeTot, showDouble timeInh, showDouble timeInd]) ++
    "  " ++ 
    [spc ++ (if name `Set.member` xs then link else colouredName) ++ 
     col (" (" ++ show entries ++ ")")]
    where
        link = "<a href='#" ++ show (hash name) ++ "'>" ++ colouredName ++ "</a>"
        colouredName = col name
        col = colourText indent
        spc = replicate (indent * 2) ' '

colourText :: Int -> String -> String
colourText 0 text = text
colourText i text = "<span style=\"color: " ++ colour i ++ "\">" ++ text ++ "</span>"

colour :: Int -> String
colour = go . (`rem` noColours)
  where
  go 0 = -- some CSS colour
  go 1 = -- some other CSS colour
  -- etc.
  noColours = -- TBD

colourText 0 = id, so that top-level text will retain the default colour. I haven't tested this, but hopefully you get the idea.

I'd be happy to create a pull request, if you agree to this change. I'm not fussed about what the colours should be, although they should ideally be accessible to colourblind developers. Presumably there's an appropriate palette that I could use somewhere online.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions