Add IGNORE content type in pre-processing#4879
Conversation
|
The PR preview for aae2a82 is available at theforeman-foreman-documentation-preview-pr-4879.surge.sh No diff compared to the current base |
Assembly files don't include the :_mod-docs-content-type: attribute that Vale DITA linting expects. This adds a preprocessing step that automatically injects the metadata for assembly files before linting. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Assembly files no longer need the :_mod-docs-content-type: ASSEMBLY attribute at the beginning. The preprocessing script in the Vale DITA workflow now injects this metadata automatically during linting. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
adbee9c to
c83cf53
Compare
|
While I like this approach, won't it just silence the vale check but still present problems during the actual migration? Assemblies should be converted to DITA maps in the migration, and the migration workflow might be looking for :_mod-docs-content-type: ASSEMBLY for that conversion. But I suppose that will also apply to the manual :_mod-docs-content-type: IGNORE approach. So among the two approaches, I think this one is preferable. No matter which path we choose, we should also add a note to Contributing. |
I (vaguely) recall a conversation with the author of https://github.com/jhradilek/asciidoctor-dita-vale/ where he said that adding content types during pre-processing was a valid solution. For the IGNORE type, I think it is safe. (It's not that any other Vale checks depend on IGNORE being present, it just disables all the checks.) For the other content types, it might be more tricky, which is why I'm not suggesting to add those to pre-processing. However, a solution certainly exists -- we could add those content types during the downstream sync, or the migration team could implement similar pre-processing on their side.
|
To be honest, I don't think that's necessary because CONTRIBUTING.md currently doesn't mention a content type for assemblies at all: foreman-documentation/CONTRIBUTING.md Lines 156 to 161 in d95c628 Unlike the other content types, which are mentioned below these lines. For contributors, this IMHO doesn't represent anything they would need to actively be aware of -- the assembly files get ignored silently under the hood, which the best way to ignore something ;) |
maximiliankolb
left a comment
There was a problem hiding this comment.
I left two comments & will reproduce the rest of the diff later locally.
There was a problem hiding this comment.
I think that you can basically shorten this script to
find . -type f -name "assembly_*.adoc" | xargs sed --in-place "1iBLUB\n"
Replace "blub" with the attribute. Note that this does not work locally as expected because git reports a different diff because the assemblies already have the attribute set. So it works, but git diff shows a weird diff 🙃
There was a problem hiding this comment.
The way the script is written is designed to avoid the need to modify the original files. That's why it creates copies in a temp directory.
Then there are also some extra bits for potential debugging purposes (warning messages, tracking file count), which could also be useful, especially if/when we add more content types to the mix later.
As I stated before, this PR was drafted by AI and AI is known to write more lines than are sometimes necessary 🙃 When I reviewed it, it seemed to make sense to make it more robust -- especially that part about copying the files to a temp directory rather than modifying them directly 🤷
|
I dropped the (now unnecessary) step to make the preprocessing script executable, and explained my reasoning for keeping the script a bit more robust than a Then I also fixed the script to inject IGNORE rather than ASSEMBLY, which I totally missed before 🙈 To test the PR, I performed the following steps:
Is this enough to check that it's working as intended? Am I missing anything? |
Yes. |
|
Now that I'm looking at it as a whole, should we just modify the Vale workflow to process only guides/common/modules rather than guides/common? If the point is to tell Vale to IGNORE the assembly files, should we just exclude them? Isn't that the best kind of ignoring? |
Yes, good call. |
|
Let's explore that approach in #4893 |
|
#4893 seems to be a much simpler and the preferable way to resolve the ASSEMBLY errors. However, I'm keeping this PR open in draft state because it's worth revisiting in the future when/if we decide to move the other content types (the ones in module files, which remain mandatory) to pre-processing. |
What changes are you introducing?
Why are you introducing these changes? (Explanation, links to references, issues, etc.)
Each assembly and module must include a content type definition to be evaluated by asciidoctor-dita-vale (https://github.com/jhradilek/asciidoctor-dita-vale/blob/af6c00940de1ce99994ddd1631aa18d35a7ff0a3/README.md?plain=1#L130). With this PR, I'm trying to avoid the need to include the IGNORE content type definition in assembly files by injecting the module type before the Vale check runs.
This saves us the need of adding two lines into 165 files that literally just say "ignore this file".
Anything else to add? (Considerations, potential downsides, alternative solutions you have explored, etc.)
Made with Claude but reviewed by myself to the best of my abilities 🙃
Contributor checklists
Please cherry-pick my commits into: