jolly-good-toolbelt / sphinx_gherkindoc

A tool to convert Gherkin into Sphinx documentation
https://jolly-good-toolbelt.github.io/sphinx_gherkindoc/
11 stars 10 forks source link

Allow users to control step keyword format via CSS #19

Closed rbcasperson closed 4 years ago

rbcasperson commented 4 years ago

So this came from a simple ask to be able to make the step keywords blue (take a guess who wanted that!), but I think it opened up a really nice option to be able to hook in some CSS classes into certain parts of the gherkin, then let the user decide whether or not to format those things, based on a static CSS file that they control themselves (and that this tool need not know about).

This start by supporting the .step-keyword class on all step keyword elements (I think it creates <span class="step-keyword">Given</span>, but we can easily do the same for all sorts of things, like feature names, scenario titles, full steps, etc.

The nice thing is that all this tool has to do is make the class available to the right <span>s, and the user can do whatever they want, with the full flexibility of CSS at their fingertips.

rbcasperson commented 4 years ago

It appears that tests aren't run in CI because this PR should fail.

bbrownjc commented 4 years ago

Yep - looks like we need to add the ./run-tests.py into https://github.com/jolly-good-toolbelt/sphinx_gherkindoc/blob/master/.travis.yml#L13

rbcasperson commented 4 years ago

Yeah I'll 1) fix the tests here, then 2) add that to travis

rbcasperson commented 4 years ago

PR updated with passing tests in CI. Here's what it looks like in a practical example:

We have in our _static folder (gets copied over during our docs build process) a .css file that contains this:

.step-keyword {
    font-weight: bold;
    color: blue;
}

Here's what the text looked like before adding that to the CSS file:

before

And here is what it looks like after:

after

Though really the important part is that whatever I put in the CSS is applied to just the step keywords.

rbcasperson commented 4 years ago

Assigned back to Brad to see if he wants to confirm the latest commits, and then it should be ready for Doug's official review when he has the chance

rbcasperson commented 4 years ago

Gotta use those browser profiles!

rbcasperson commented 4 years ago

Well, looks like I have 2 approvals! :trollface:

dgou commented 4 years ago

I guess both Brad's right and left brains have approved!