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

allow supplying a custom metadata format parser for compiler #529

Open
3 of 6 tasks
lennart opened this issue Mar 10, 2017 · 1 comment
Open
3 of 6 tasks

allow supplying a custom metadata format parser for compiler #529

lennart opened this issue Mar 10, 2017 · 1 comment

Comments

@lennart
Copy link

lennart commented Mar 10, 2017

currently hakyll seems to be only able to read metadata as YAML (as far as I understand the code in Provider/Metadata.hs)

I want to be able to have hakyll keep source code function documentation in metadata as key value pairs (functionname: functiondocstring) when compiling source code files.

big picture is

  • route to a pattern of haskell source files, compile with a custom Compiler
  • then build a map of all functions (docs) found in all files given by a pattern (similar to buildTags but not quite)
  • then write function references within markdown pages as standard yaml metadata list field
  • build a map of those function references
  • match them against the function docs by their identifiers (function names)
  • render the markdown page with content & a list of rendered functionname/functiondocstrings

So in order to do that (as the docstrings do not appear in single files and I cannot find another way to do the above) I was thinking of a custom Metadata parser (I can provide) that essentially parses haskell source code into an AST and extracts the function names and docstrings into a Metadata object.

How would that be possible? I am not hesitant to put this into a contrib module, as I fear this is a rather non-standard feature request.

However right now, I think I would need to fork hakyll in order to do that, and I would rather not.

suggestions on how to proceed?

kindly,

lennart

@jaspervdj
Copy link
Owner

I don't think you necessarily need to do this through metadata, I think you can approach it from a different angle as well.

What I suggest is the following flow:

  1. Compile all source files to a custom datatype (e.g. DocMap). Use a version "docmap" here to distinguish it.
  2. Add a compiler which loads all DocMaps produced in (1) and mconcats them together to get a "global" DocMap.
  3. Compile all source files "normally" but load the global DocMap so you can use that to render the table of context and so on.

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

No branches or pull requests

2 participants