Coder Social home page Coder Social logo

parseDocs's type about documentalist HOT 7 CLOSED

jspahrsummers avatar jspahrsummers commented on September 26, 2024
parseDocs's type

from documentalist.

Comments (7)

jspahrsummers avatar jspahrsummers commented on September 26, 2024

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.

mxswd avatar mxswd commented on September 26, 2024

Ah I see. Yeah.

from documentalist.

jspahrsummers avatar jspahrsummers commented on September 26, 2024

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.

mxswd avatar mxswd commented on September 26, 2024

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.

jspahrsummers avatar jspahrsummers commented on September 26, 2024

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.

mxswd avatar mxswd commented on September 26, 2024

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.

mxswd avatar mxswd commented on September 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.