Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

I would like to improve the API documentation #142

Open
marick opened this issue Apr 6, 2018 · 8 comments
Open

I would like to improve the API documentation #142

marick opened this issue Apr 6, 2018 · 8 comments

Comments

@marick
Copy link

marick commented Apr 6, 2018

I come from Elm. I find its API documentation helpful because the more common functions are at the beginning.

I'm not criticizing! I want to help!

Here's the first 5 documented functions from Dict:

Build (major category)
- empty
- singleton
- update
- insert
- remove

Here are the first 5 from Data.Map:

- showTree
- empty
- isEmpty
- singleton
- checkValue

I think the Elm API documentation is better. checkValue is not important. When i want to look for a function, I find it faster in the Elm documentation.

Elm has the advantage that their doc format lets you categorize. Still, I think Data.Map API documentation could be improved with better organization. People who haven't memorized the key parts of the API want to know whether the "add a new element" function is add or insert without having to scroll past lookupLt, lookupGE, lookupGT, findSubMap, and subMap.

I volunteer to reorganize the functions in the source to put the more common ones first, if someone says they'd accept such a pull request.

@michaelficarra
Copy link

Maybe it would be enough if the documentation generator had a way to mark some exports as "priority" for documentation purposes?

@hdgarrood
Copy link
Contributor

hdgarrood commented Apr 7, 2018 via email

@marick
Copy link
Author

marick commented Apr 7, 2018

Will do some rearranging.

@marick
Copy link
Author

marick commented Apr 7, 2018

I've confirmed that moving

-- | Render a `Map` as a `String`
showTree :: forall k v. Show k => Show v => Map k v -> String
...

... to the end of the file does in fact put at the end of the generated-doc list.

But rearranging the file to match the order given above is pretty problematic given 11 pull requests.

@hdgarrood
Copy link
Contributor

Are you using an old compiler?

@marick
Copy link
Author

marick commented Apr 8, 2018

I see I was not. (0.11.6 instead of 0.11.7) .

(Why does npm -g update not update purs, given that no argument is supposed to update everything? I had to give npm -g update purescript.

In any case, that fixes the ordering.

@marick
Copy link
Author

marick commented Apr 8, 2018

(And what happened to the comment where I reported the problem? It had the version numbers, but more importantly, I was hoping for a thumbs-up on the proposed order before fashioning a pull request.)

module Data.Map
  ( Map
  -- creation  
  , empty
  , singleton
  , fromFoldable
  , fromFoldableWith

  -- common ops
  , lookup
  , insert
  , delete

  -- queries
  , member
  , size
  , isEmpty

  -- manipulation of keys and values
  , keys
  , values
  , mapWithKey

  -- less common
  , update
  , alter
  , pop
    
  -- setlike
  , union
  , unionWith
  , unions
  , isSubmap

  -- filters
  , filter
  , filterWithKey
  , filterKeys

  -- taking advantage of Ord
  , lookupLE
  , lookupLT
  , lookupGE
  , lookupGT
  , findMin
  , findMax
  , submap
  , foldSubmap

  -- Unfoldable
  , toUnfoldable
  , toAscUnfoldable

  -- utils
  , showTree
  , checkValid
  ) where

@hdgarrood
Copy link
Contributor

That looks good to me, yep!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants