rune icon indicating copy to clipboard operation
rune copied to clipboard

Document built-in modules

Open udoprog opened this issue 1 year ago • 0 comments

Since #464, native modules can now be documented.

Missing features:

  • Generating links from full rune paths.
  • Running documentation tests. This ensures that the documentation is correct and as a bonus ensures that public features are tested.

This is a tracking issue for modules and functions which are still lacking documentation.

  • [x] ::std::any
  • [x] ::std::bytes
  • [x] ::std::char
  • [x] ::std::cmp
  • [x] ::std::collections
  • [x] ::std::core
  • [x] ::std::float
  • [ ] ::std::fmt
  • [ ] ::std::future
  • [ ] ::std::generator
  • [x] ::std::int
  • [ ] ::std::io
  • [x] ::std::iter
  • [ ] ::std::macros
  • [x] ::std::mem (#474)
  • [x] ::std::object
  • [x] ::std::ops
  • [x] ::std::option
  • [x] ::std::result
  • [ ] ::std::stream
  • [x] ::std::string
  • [ ] ::std::test
  • [x] ::std::vec

Since many functions mimic what's available in Rust, documentation from there can be adapted for Rune, such as this example from is_alphabetic (see Rust version here). The appropriate licensing attribution will be added before this is released.

/// Returns `true` if this `char` has the `Alphabetic` property.
///
/// `Alphabetic` is described in Chapter 4 (Character Properties) of the [Unicode Standard] and
/// specified in the [Unicode Character Database][ucd] [`DerivedCoreProperties.txt`].
///
/// [Unicode Standard]: https://www.unicode.org/versions/latest/
/// [ucd]: https://www.unicode.org/reports/tr44/
/// [`DerivedCoreProperties.txt`]: https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt
///
/// # Examples
///
/// ```rune
/// assert!('a'.is_alphabetic());
/// assert!('京'.is_alphabetic());
///
/// let c = '💝';
/// // love is many things, but it is not alphabetic
/// assert!(!c.is_alphabetic());
/// ```
#[rune::function(instance)]
#[inline]
fn is_alphabetic(c: char) -> bool {
    char::is_alphabetic(c)
}

Future

  • Type and variant level documentation is not yet supported. But is expected to be produced through the Any derive.
  • Documentation for vm-accelerated functionality is still missing. Such as vector indexing. Once support for this is added, those will be added to this as well.

udoprog avatar Mar 25 '23 09:03 udoprog