-
Notifications
You must be signed in to change notification settings - Fork 3
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
Source file standard license headers #75
Comments
Hello @jhenahan, thanks for reporting this, I'll have closer look. By the way, is the project where you try to use headroom publicly accessible somewhere (so I can eventually check your configuration and/or recommend you some fixes if possible)? |
It's not currently public, but I expect it will be eventually. Here's a reproducer: Relevant settings:variables:
_haskell_module_longdesc: |-
!!! Write a description !!!
license-headers:
haskell:
put-after: ["^{-#"]
block-comment:
starts-with: ^{- \|
ends-with: (?<!#)-}$ Inlining the text{- |
Module : {{{ _haskell_module_name }}}
Description : {{{ _haskell_module_shortdesc }}}
Copyright : {{ _current_year }} {{ author }} <{{ email }}>
SPDX-License-Identifier : {{ spdx }}
Maintainer : {{ email }}
Stability : experimental
Portability : POSIX
@
This file is part of {{ project }}.
Copyright {{ _current_year }} {{ author }}
{{{ license_text }}}
@
{{{ _haskell_module_longdesc }}}
-} This is is fine in {- |
Module : {{{ _haskell_module_name }}}
Description : {{{ _haskell_module_shortdesc }}}
Copyright : {{ _current_year }} {{ author }} <{{ email }}>
SPDX-License-Identifier : {{ spdx }}
Maintainer : {{ email }}
Stability : experimental
Portability : POSIX
@
This file is part of {{ project }}.
Copyright {{ _current_year }} {{ author }}
{{{ license_text }}}
@
@
This file is part of {{ project }}.
Copyright {{ _current_year }} {{ author }}
{{{ license_text }}}
@
{{{ _haskell_module_longdesc }}}
-}
module Main where That is, the comment (actually rendered in my files, rather than untemplated as in this example) ends up duplicated on every run. I suspect that what's happening is that on subsequent runs,
so it (correctly, but unintentionally) inlines the comment a second (third, etc.) time. Separate comment{- |
Module : {{{ _haskell_module_name }}}
Description : {{{ _haskell_module_shortdesc }}}
Copyright : {{ _current_year }} {{ author }} <{{ email }}>
SPDX-License-Identifier : {{ spdx }}
Maintainer : {{ email }}
Stability : experimental
Portability : POSIX
{{{ _haskell_module_longdesc }}}
-}
{-
This file is part of {{ project }}.
Copyright {{ _current_year }} {{ author }}
{{{ license_text }}}
-} Again, this works fine in {- |
Module : {{{ _haskell_module_name }}}
Description : {{{ _haskell_module_shortdesc }}}
Copyright : {{ _current_year }} {{ author }} <{{ email }}>
SPDX-License-Identifier : {{ spdx }}
Maintainer : {{ email }}
Stability : experimental
Portability : POSIX
{{{ _haskell_module_longdesc }}}
-}
{-
This file is part of {{ project }}.
Copyright {{ _current_year }} {{ author }}
{{{ license_text }}}
-}
{-
This file is part of {{ project }}.
Copyright {{ _current_year }} {{ author }}
{{{ license_text }}}
-}
module Main where and so on for additional runs.
|
@jhenahan big thanks for the reproductions steps. I'm afraid this one will not be trivial and unfortunately I'm not aware of any workaround at this moment. The thing is that I'm reusing piece of code from Haddock that parses Haddock header and from Haddock point of view, everything after that Regarding your proposed solutions, IMO the post-processor could be way to go, but I'll need some more time to think about it. But I think it should be possible to just add new post-processor that would allow to define preamble/postamble with either specific behaviour to the Haddock headers, or maybe it could be even more generalized also for other types of source codes so end-user would be able to define some rules (regex?) where exactly to insert the extra snippet. What I can think about at this moment, this is probably easiest and cleaniest way to go. I'd really like to avoid touching the Haddock parsing behaviour, as I'd like to keep as much on track with actual Haddock implementation as possible. |
Totally onboard with maintaining the Haddock integration as is. 👍 I'll see if I can grok the postprocessing machinery and try a PR once I'm through a bit of what I'm working on now. Thanks very much for the explanation and the pointers! |
I think I'll have some free time to have a look and eventually start the implementation, it should be relatively straightforward. 🙂 |
Is there a straightforward way to add a standard license header (in my specific case, to a Haskell source file)? That is, I'd like to be able to have a comment like
I tried a couple of hacky ways that have their own tradeoffs:
_haskell_module_longdesc
greedily consumes everything up tomodule
_haskell_module_longdesc
avoids duplication, but changes to the component variables are (correctly, if unhelpfully in this case) never picked upI'm not particularly happy with either of those, but I figured I'd see if there was maybe an undocumented footer variable or something that I could co-opt for the purpose.
If this isn't currently possible, I'd likely be interested in putting in some work to get something working. In that event, would you imagine this would be best handled with
license-headers
key (maybe,pre/postamble
orfooter
or something)_haskell_module_longdesc
less greedyThe last one feels like a scary regex mess waiting to happen, so I'm hopeful one of the other options would be a sensible place to start.
Thanks for Headroom and any input!
The text was updated successfully, but these errors were encountered: