A PR to look over would be good.

On Sun, Apr 6, 2025 at 9:41 AM Bear Giles <bgi...@coyotesong.com> wrote:

> I've been working on a contribution to maven-dependency-plugin and spent a
> fair amount of time trying to figure out how to cleanly implement proper
> indentation when converting the dependency tree to json, yaml, etc.
>
> After a bit of pain, okay a lot of pain, I have finally implemented a new
> Directive - 'indent' - which extends Block and prepends a 'padding' value
> on render(). This works since render() is also called recursively.
>
> (I know there's a TreeContext but I have no idea how to use it, whether it
> can be used within the existing plugin, or even if it would help solve this
> problem.)
>
> An example of how it is used is:
>
> #macro (writeNodeAsJson $node)
> // do the json magic
> #end
>
> #macro (walktree $node)
> #indent
>    #writeNodeAsJson($node)
>    #foreach ($child in $node.children)
>       #walktree ($node)
>    #end
> #end
> #end
>
> (I don't have that code on this system so there may be a slight error in
> it.)
>
> At the moment the directive doesn't take any parameter but I do plan to add
> an optional one, ideally either a string literal or a reference, but I
> haven't coded it yet. In theory it could even be a reference to a different
> macro, e.g., so you could have 'I", "II",... then 'a','b'..., then
> '1','2'... since the macro could be provided the current indentation depth
> but I'll leave that for another day.
>
> I think I have JIRA access and if so I'll create an issue and submit a PR.
>
> Bear Giles
>

Reply via email to