Greg Hurrell [Tue, 7 Jun 2016 16:26:51 +0000 (09:26 -0700)]
Add Section visitor
It's job is to check which kinds of annotations we have, in order to decide
which sections we need to render.
I am probably doing something clowny with the way I am mashing uniplate and
lenses etc together, but it does seem to work. That last `get`/`put` case is a
smell, but needed it given my use of `cosmosOf`; not sure how to avoid that.
Also, not sure why `mapM` does the right thing here, but it does.
Greg Hurrell [Tue, 7 Jun 2016 14:29:42 +0000 (07:29 -0700)]
Try to trick linter about duplication
It's been warning about this since forever:
```
Found:
first <- firstLine
rest <- many otherLine
let nodes = concatMap appendWhitespace (first : rest)
let compressed = compress nodes
return
(if last compressed == Whitespace then init compressed else
compressed)
Why not:
Combine with lib/Docvim/Parse.hs:202:7
lib/Docvim/Parse.hs:164:7: Warning: Reduce duplication
Found:
first <- firstLine
rest <- many otherLine
let nodes = concatMap appendWhitespace (first : rest)
let compressed = compress nodes
return
(if last compressed == Whitespace then init compressed else
compressed)
Why not:
Combine with lib/Docvim/Parse.hs:285:7
```
However, it is too smart. Even with this change, it still complains:
```
Found:
first <- firstLine
rest <- many otherLine
let nodes = concatMap appendWhitespace (first : rest)
let compressed = compress nodes
return
(if last compressed == Whitespace then init compressed else
compressed)
Why not:
Combine with lib/Docvim/Parse.hs:282:7
lib/Docvim/Parse.hs:165:7: Suggestion: Reduce duplication
Found:
rest <- many otherLine
let nodes = concatMap appendWhitespace (first : rest)
let compressed = compress nodes
return
(if last compressed == Whitespace then init compressed else
compressed)
Why not:
Combine with lib/Docvim/Parse.hs:203:7
```
This one is tricky to factor out because of the dependence on bindings visible
within the scope of the defined functions, and also the monadic execution
context. I think the linter *is* probably right that there is a code smell here,
though; I just have to figure out how to remove it.
Greg Hurrell [Tue, 7 Jun 2016 02:04:40 +0000 (19:04 -0700)]
Make wrapping aware of concealed characters
This is the cheap-but-approximate approach. Results are reasonable, costs are
very low, and the consequences of being (slightly) wrong are livable. Let's go
with this for now.
Greg Hurrell [Mon, 6 Jun 2016 13:55:27 +0000 (06:55 -0700)]
Initial cut at @mapping, @command, @option, @function
Still some bugs to sort out (eg. duplicate symbol table entry due to extra
`MappingsAnnotation` when we perform extraction) and polish to apply (not
actually printing the options/functions etc).
Greg Hurrell [Sun, 5 Jun 2016 14:06:32 +0000 (07:06 -0700)]
Overhaul testing and compilation
We now "compile" in the test suite, meaning that we pipe our translation units
through the various extraction transforms after parsing. This means three main
things:
- Everything is nested inside a `Project` node type now, consisting of one or
more translation units.
- Nodes within the project are ordered (or reordered) to maintain desired
section ordering.
- As we add more phases to "compilation" (eg. automated insertion of table
of contents etc), these will get reflected in the test suite automatically.
As part of this, extracted test-specific bits out into a new `Util` module (ie.
pretty-printing methods, convenience functions) and the "compile" pipeline into
a `Compile` module.
Greg Hurrell [Sat, 4 Jun 2016 22:01:56 +0000 (15:01 -0700)]
Move hardwrapping from `plaintext` into `append`
Solves a bunch of issues, creates others, which I will have to fix in a
follow-up. The code itself is a complex, fragile, ugly, clusterfuck, so consider
this a work-in-progress.
Additionally, there are some unfortunate breaks which were there before and
continue to be there, like just inside parens, and things like that. Will need
to sort all that out too.
Greg Hurrell [Wed, 1 Jun 2016 17:27:28 +0000 (10:27 -0700)]
Use operations list in Vim printer
Let's see if I can use this to implement hard-wrapping. It is very ugly, but if
I can get it working I'll have some tests in place and can then try refactoring.
The order in which I compose the State and Reader monad transformers shouldn't
matter at all. If I end up needing Writer too, I will be able to replace this
with the RWS monad transformer.
Greg Hurrell [Tue, 31 May 2016 14:21:34 +0000 (07:21 -0700)]
Rename `State` to `Metadata`
State was a terrible name to use in conjunction with the Reader monad, as it
easily leads to confusion with the State monad. Let's just call it `Metadata`
(about the project AST) for now; that's a horribly generic name too, but it is
at least an improvement.