Comments (7)
It would be helpful to include some kind of diagnostic information, since otherwise it'll be very unclear why documentation wasn't generated for a comment.
from documentalist.
Ah I see. Yeah.
from documentalist.
Well, I think the thrust of this is still valid. Comment parsing should probably not be fatal, so your other idea of parameterizing with an Either CommentParseException DocBlock
makes sense.
from documentalist.
We could make DocBlock
's summary a Maybe
.
Then if you have no comments, you still get a DocBlock
where all the fields are mempty
.
data DocBlock = DocBlock
{ summary :: Maybe Paragraph
, description :: [Paragraph]
, parameters :: [DocParam]
, example :: Maybe Code
, result :: Maybe Result
} deriving Eq
from documentalist.
That still doesn't really solve the problem I alluded to. We need to notify the user somehow when parsing a specific comment fails.
from documentalist.
Assuming all comment parsing exceptions are non fatal (I think this is ok);
parseDocs
can return a Package (Either CommentParseException DocBlock)
.
Then your main function must have some function to map it to Package (Maybe DocBlock)
so you can put it into write :: Package (Maybe DocBlock) -> w ()
.
Something like:
showErrors :: Either CommentParseException DocBlock -> IO (Maybe DocBlock)
showErrors (Left e) = hPutStrLn stderr (show e) >> return Nothing
showErrors (Right x) = return $ Just x
The reason I brought up it as an instance of Monoid, is that function would be:
showErrors (Left x) = hPutStrLn stderr (show x) >> return mempty -- shows the CommentParseException
showErrors (Right x) = return x
And write
would be Package DocBlock -> w ()
Also this changes #39, because this traversal is the Traversable
one, so I guess we should have both the current one we have and a more refined version for the type.
from documentalist.
I thought about it a bit more, and when you are writing the docs, you want to know if it is Nothing
(i.e. no comments were on that function), so Either CommentParseException DocBlock -> IO (Maybe DocBlock)
is good. And lets not do a Monoid.
from documentalist.
Related Issues (20)
- Use MonadError for SourceParsers HOT 6
- Allow any MonadIO for SourceParsers HOT 1
- Configure warning HOT 2
- Clang frontend parses too early HOT 2
- Tidy parseComment type HOT 2
- Improve comment marker stripping
- Duplicate documentation found when forward-referencing a class HOT 14
- Variadic arguments
- #imported headers should not be included in the Module
- Declarations not found outside of the Module and explicit #imports
- Appledoc/HeaderDoc-esque Writer
- Safe Haskell support for Clang frontend
- Tests for TomDoc parsing
- Strikethrough Span HOT 1
- Runtime error HOT 1
- Build problems HOT 4
- Travis needs a new repo for llvm-3.4
- Swift doc generation HOT 1
- Make Clang functions pure HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from documentalist.