Skip to content

Documentation and docstrings #25

Open
@zth

Description

@zth

A goal for Core is to provide a really solid developer experience. One important piece in doing that is providing good documentation, and good docstrings. For those who don't know, docstrings are the strings you prepend functions etc with to explain what they are. They show up via the editor tooling on hovering, auto completion, etc. Example from Promise.resi: https://github.com/rescript-association/rescript-core/blob/main/src/Core__Promise.resi#L11-L17

We will need help to do this. Crafting good docstrings takes time, and there's a fairly large API surface to cover.

Eventually, these docstrings will also be extracted and used for real documentation, via the doc extraction project that's in the works.

Current state

  • Array
  • AsyncIterator
  • Console
  • Date
  • Dict
  • Error
  • Float
  • Global
  • Int
  • Iterator
  • JSON
  • List
  • Map
  • Math
  • Null
  • Nullable
  • Option
  • Promise
  • RegExp
  • Result
  • Set
  • String
  • Type
  • Undefined
  • Symbol
  • BigInt
  • Intl Collator
  • Intl DateTimeFormat
  • Intl Locale
  • Intl NumberFormat
  • Intl PluralRules
  • Intl RelativeTimeFormat
  • Object
  • ArrayBuffer
  • BigInt64Array
  • BigUint64Array
  • Float32Array
  • Float64Array
  • Int8Array
  • Int16Array
  • Int32Array
  • TypedArray
  • Uint8Array
  • Uint8ClampedArray
  • Uint16Array
  • Uint32Array
  • WeakMap
  • WeakSet
  • DataView

Suggested format

  1. Describe the thing in a sentence or two. Keep this short. Good to be inspired by MDN for example.
  2. Write a ReScript example in code, inside ```rescript notation. This is important and I think we should aim to have this for everything it makes sense for.

This example (and the rest in that file) is a good guide: https://github.com/rescript-association/rescript-core/blob/main/src/Core__Promise.resi#L11-L17

Workflow

I propose the following workflow:

  1. Look up a module in the project that you want to start working on.
  2. Generate a .resi file for the module, if it doesn't have one already. We aim for all modules having resi files, and to keep the documentation in there.
  3. Write in this thread that you'll start working on said module.
  4. Start working, and open a WIP PR. Commit and push often. This is so that others can pick up where you left off if needed.

I can recommend having the compiler running as you work on docstrings, and then use TempTest.res to get immediate feedback on your changes. Just use whatever you're working on and hover it in there and you'll see how the docstrings render immediately.

Editor integration

We want to make using Core an as pleasant experience as possible. Part of that is also that the editor tooling behaves the way we want it to with regards to docstrings etc. #3 this issue covers that, feel free to post things you discover in there.

Open questions

First off, please give feedback on the format, so we can ensure we cover everything we want to cover. Here are some additional open questions:

  • Should we suggest alternatives in the docstrings? This is particularly important for things like mutable APIs, like Map which binds to the native JS Map, where Belt.Map is an immutable alternative.
  • On the same theme, should we highlight clearly what things are mutable? More discussion in this thread: [Discussion] Immutable defaults for mutable JS API:s #23
  • Should we add links to the website docs where applicable? Concepts involved in using the thing, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions