LightGuard / asciidoc-splitter

A splitter utility for helping create modular docs from chapter files.
BSD 2-Clause "Simplified" License
8 stars 8 forks source link

Don't generate `parent-context` conditionals during the split OR modify to only add if not present already #61

Closed sterobin closed 4 years ago

sterobin commented 4 years ago

Current behavior

The splitter automatically generates the parent-context conditionals that are recommended by the FCC guidelines:

ifdef::context[:parent-context: {context}]
...
ifdef::parent-context[:context: {parent-context}]
ifndef::parent-context[:!context:]

Although this behavior is handy, these conditionals should already be defined in the source chapter anyway for the same reason of controlling the context definitions in community chapters as well. It's not an enterprise-only feature, but a way to ensure that chapters within chapters or assemblies within assemblies have proper control over the context definition. So if this is already defined in the source manually by the writer, as it typically will/should be, then I assume the splitter might duplicate it when splitting for enterprise.

Desired behavior

To avoid duplicate parent-context conditionals, the splitter should either detect if those conditionals are present in the chap source and not add them if they are present, or simply not bother adding them and leaving it to the writer to do manually in the source or not. Whichever route is easier. I'm sure the latter is easier :)

sterobin commented 3 years ago

@LightGuard , the splitter is still generating the parent-context opener and closers even if they are already present. I wanted to re-open this issue, but won't let me. I suggest just disabling it from creating parent-context opener and closers at all, imo. These need to be added manually in the source anyway for the benefit of the source. Even if we can get it to successfully detect if it's present and add if not, it's just another dependency on a CCS template element that I think might change. So to simplify, just nix imo.

This is what I'm getting after the split today, for example. I've flagged the DUPLICATE lines (first line and the ante-penultimate line). It doesn't duplicate the final ifndef though.

ifdef::context[:parent-context: {context}]  <-- DUPLICATE
[id='assembly-kogito-creating-running']
= Creating and running your first {PRODUCT} services
ifdef::context[:parent-context: {context}]
:context: kogito-creating-running

// Purpose statement for the assembly

As a developer of ...

...

ifdef::parent-context[:context: {parent-context}]  <-- DUPLICATE

ifdef::parent-context[:context: {parent-context}]
ifndef::parent-context[:!context:]