kozross / hotteok Goto Github PK
View Code? Open in Web Editor NEWThe next generation in Haskell documentation
The next generation in Haskell documentation
Documenting some things in Haddock is needlessly difficult. A good (and flaky) example is trying to document DerivingVia
derivations:
-- | Some stripey data type.
newtype Foo = Foo Bar
deriving ( Semigroup -- ^ @since 4.10
, Monoid -- ^ @since 4.12
) via (Sum Bar)
This is extremely icky and quite awkward to write. If we make the 'new-style' documentation comments lean more on annotations, we could replace it with something like this:
-- hotteok:
--
-- Some stripy data type.
-- @deriving
-- Semigroup
-- @since 4.10
-- @deriving
-- Monoid
-- @since 4.12
newtype Foo = Foo Bar
deriving (Semigroup, Monoid) via (Sum Foo)
This is an interesting possibility. If we can generate DocBook, we can then potentially render it into a wide range of formats, rather than limiting ourselves to HTML.
Having to rely on GHC for linkage information is probably inevitable to some degree. However, we could store that in an embedded database, which means that future rebuilds will only need to call out to GHC for stuff that's stale.
Based on #3, these are some of the annotations we should add in my opinion:
@see
, functioning as a 'See also' section, similar to the one in JavaDocs@deriving
, as per #3.@law
for type class laws@method
for documenting individual methods of a type class@throws
for indicating what exceptions people should expect to have to catch from this function@totality
to describe whether something is total or partial@unsafe
for functions that should be used with care, like unsafePerformIO
Any others?
LaTeX is a complex beast, and rendering it is no mean feat (even Pandoc basically gives up and outsources it). Having it be supported in the 'new-style' documentation comments is probably unnecessary as well, since most people only want a small amount of functionality LaTeX actually offers.
AsciiMath seems to offer some reasonably pleasant syntax for basically everything folks would want from LaTeX in a documentation generator, and embedding it (as well as natively rendering) is quite easy. Should we use this instead?
It seems almost a complete no-brainer, as the needs served by Cabal overlap with ours considerably.
Haddock has a set of 'documentation markers' indicating that the comment in question is to be treated as documentation to render:
-- | This is a Haddock comment.
foo :: String
foo = "bar"
instance Foo Bar where
quux = id -- ^ So is this.
Should we maintain this behaviour for the 'new-style' documentation comments? I was thinking that something like this would be good:
-- hotteok:
-- The rest is documentation.
foo :: String
foo = "bar"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.