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

Added LanguageConfig concept, implemented function_macro_prepend option #226

Closed
wants to merge 11 commits into from

Conversation

pixsperdavid
Copy link
Contributor

In order to allow easier customisation of generated header files on a per-language basis, I've expanded the Language enum to contain a per-language configuration (CLanguageConfig, CSharpLanguageConfig, etc.), which is then propagated to methods of HeaderLanguage implementers. Consequently I have renamed Language to LanguageConfig to better describe this new function.

The first config option I have added is based on my query in #202, which allows optional insertion of a custom macro text before each function definition. There's a good deal of other potential config options I'd like to add but holding off until I get approval on this approach for adding the LanguageConfig struct to contain and distributed this.

@danielhenrymantilla
Copy link
Collaborator

Thanks! I had something like that in the back of my mind, but never got to implement it (I have a slightly more dynamic/extensible idea using "the Provider pattern" (don't have the time to look up a link right now; it was suggested around the Error trait in the stdlib but rejected there, even though as third-party libs we can roll our own).

  • My goal longer-term is to get rid of the idea of an enum of languages altogether, and just have a whole trait API define how to render headers for a given language or language style, whilst also having, at the other end of the pipeline (at the "generate headers call"), a way to smuggle config info which the "language"/specific trait implementation could dynamically query.

But since the current code does hard-code C/C# branches, the version you are currently offering is definitely a great fit!


Since this a rather major PR, I will wait a bit to be testing it on other codebases and whatnot, but if in 2-3 weeks I haven't come back to this, do ping me, and we'll work on merging and releasing it 🙂

@pixsperdavid
Copy link
Contributor Author

pixsperdavid commented Jul 15, 2024

My goal longer-term is to get rid of the idea of an enum of languages altogether, and just have a whole trait API define how to render headers for a given language or language style, whilst also having, at the other end of the pipeline (at the "generate headers call"), a way to smuggle config info which the "language"/specific trait implementation could dynamically query.

I attempted to try and hide the LanguageConfig structs within the HeaderLanguage trait implementers, but it would mean adding fields to them which felt like it would be a more major structural change. Definitely something to aim for in the future though.

@pixsperdavid
Copy link
Contributor Author

pixsperdavid commented Aug 7, 2024

@danielhenrymantilla I've updated this PR for recent changes, do you have time to look at merging?

@pixsperdavid
Copy link
Contributor Author

Is there any kind of testing I can do to help expedite merging of this PR? I have quite a few other formatting features I need to build off this which I'm hesitating to add at the moment as they're only going to make it larger.

@pixsperdavid
Copy link
Contributor Author

pixsperdavid commented Oct 7, 2024

Due to development urgency, I've unfortunately had to move to another solution so can't maintain this PR going forward, happy to pass to anyone else if they would find it useful.

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