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
Extract dynamic variables from Haskell source code files #25
Comments
Thanks for writing this project! That would be a really nice feature! I've tried to run diff --git a/summoner-cli/src/Summoner/License.hs b/summoner-cli/src/Summoner/License.hs
index 1afb6ac..e61a0e5 100644
--- a/summoner-cli/src/Summoner/License.hs
+++ b/summoner-cli/src/Summoner/License.hs
@@ -1,12 +1,14 @@
-{- |
-Copyright: (c) 2017-2020 Kowainik
-SPDX-License-Identifier: MPL-2.0
-Maintainer: Kowainik <xrom.xkov@gmail.com>
-
-Data types that represent license names and license content and functions
-to work with them.
+{-|
+Module : MODULE_NAME
+Description : SHORT_DESC
+Copyright : (c) 2020 Kowainik
+License : MIT
+Maintainer : xrom.xkov@gmail.com
+Stability : experimental
+Portability : POSIX
+
+LONG_DESC
-} You can notice that it completely removes the top-level module comment, and this makes the tool unusable at the moment. |
@chshersh Thank you for your feedback! If I understand correctly your problem, you'd like to keep the very top Haddock module comment untouched by Headroom and instead Headroom should put somewhere second comment containing that license text only? Because right now the built in Haskell support actually renders the top level module Haddock comment, with the license mentioned on the |
@vaclavsvejcar I'd like to have a single top-level Haddock comment which contains both license information and top-level Haddock. Licensing information renders nicely on Hackage, so I'd like to keep it. At the same time, I don't want to have the same information duplicated in the module. So in the best case, it would be nice if Headroom could recognize existing top-level Haddock and update it. To be more precise, a diff like below would be the most desirable: diff --git a/summoner-cli/src/Summoner/License.hs b/summoner-cli/src/Summoner/License.hs
index 1afb6ac..e61a0e5 100644
--- a/summoner-cli/src/Summoner/License.hs
+++ b/summoner-cli/src/Summoner/License.hs
@@ -1,12 +1,14 @@
-Copyright: (c) 2017-2019 Kowainik
-SPDX-License-Identifier: MPL-2.0
-Maintainer: Kowainik <xrom.xkov@gmail.com>
+Copyright : (c) 2017-2020 Kowainik
+SPDX-License-Identifier : MPL-2.0
+Maintainer : Kowainik <xrom.xkov@gmail.com> Ability to specify/ignore the |
@chshersh Speaking about the Template{-|
Copyright : (c) {{ year }} {{ author }}
SPDX-License-Identifier : MPL-2.0
Maintainer : {{ email }}
Stability : {{ stability }}
Portability : {{ portability}}
-} YAML configvariables:
year: "2017-2020"
author: Kowainik
email: "Kowainik <xrom.xkov@gmail.com>"
portability: POSIX
stability: stable But to your main point - right now, the current logic for replacing headers is unfortunately pretty dumb and works in these steps:
So not only that Headroom cannot do any partial replacements of existing license header, it also cannot work with license headers that are in between the code, not before any code (I think this will be issue for #28). Unfortunately for Haskell the situation is more complex than for many other languages (Java, Scala), where the license header is usually just dummy very first comment of the source code file. Surely I'm willing to fix/extend/enhance this detection logic, but haven't yet found any nice generic approach that would cover at least these requirements:
|
- allow default values to be set in user-defined configuration - allow variable values to contain templates - code improvements, introduce 'Variables' data type
Implemented and released as part of v0.3.0.0. |
Goal of this task is to support extracting extra dynamic template variables for Haskell source code files, which would singinicantly simplify work with Haddock module headers.
The Problem
Imagine following template file for Haskell source code files:
Current version of Headroom will fill in the static variables, such as
year
andauthor
since those are same for all source code files, but there's no way to define variable values such as Haskell module name or Haddock description, as these differs file by file. This is fine when header is added to the file, as you need to fill these by hand, but when you try to replace this header with Headroom, it will overwrite your hand-written fields again with initial values.The Solution
This task adds functionality that will support extracting Haskell module name and selected fields from Haddock module header, from the currently processed Haskell source code file. If no such Haddock module is present (i.e. adding header for very first time), you'll need to fill these by hand, but next time you use Headroom to replace header, it will correctly extract and fill these variables from already present header.
In order to apply these changes, header example from above will change to:
where:
_haskell_module_name
- name of the Haskell module_haskell_module_longdesc
- long description of Haddock module_haskell_module_shortdesc
-Description
field of Haddock module headerThe text was updated successfully, but these errors were encountered: