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

Change convenience API to allow pre- and post-generation steps #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

edelabar
Copy link

From JohnSundell#70:

Changes

The convenience API publish(withTheme...) has had the parameter additionalSteps renamed to preGenerationSteps, and has gained the parameter postGenerationSteps.

This is a breaking change for anyone currently using the additionalSteps parameter, requiring them to switch to the new parameter name. It will not affect anyone using the publish(withTheme...) function but not calling the additionalSteps parameter.

Motivation

Although most PublishingSteps must be run before HTML generation, some must be run after.
For example, the HTML produced by Ink, Plot, Publish, and various plugins may be formatted and indented inconsistently. To use any kind of HTML prettifying/validation tool, you must have access to the rendered HTML in its entirety, which is not possible until after generation.

Currently, the convenience API publish(withTheme...) includes a parameter called additionalSteps, but these are applied before HTML generation. This PR splits that into two parameters, which specify steps to be run before and after generation.

Although these post-generation steps can be added using the publish(at:using:) function, it requires significantly more setup, hence the change to the convenience API.

Alternatives Considered

  1. Use the @deprecated attribute to leave the existing function and add the new one. Since the function names are the same, the compiler cannot accurately predict when to use the warning, especially when neither of the extra step parameters are in use. This causes an unfixable warning if you don't use the parameter at all.
  2. Leave additionalSteps as is, and add the postGenerationSteps parameter. This avoids the breaking change, but is more ambiguous. Steps that must be run after generation might be inadvertently added to additionalSteps due to its name.

Follow-up

Once the status of this PR is decided, I'll add some documentation demonstrating pre- and post-generation steps. I should have my TidyHTMLPublishStep repo online by then as an example.

@edelabar
Copy link
Author

I might need something like this, but I need to understand more...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants