Last active
July 11, 2017 22:02
-
-
Save Spartee/c50b458dca097e95c2919a631ddb23ed to your computer and use it in GitHub Desktop.
An interface for the Toml library written in chapel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Chapel's Library for `Tom's Obvious, Minimal Language (TOML) <https://github.com/toml-lang/toml>`_. | |
This module provides support for parsing and writing toml files. | |
Will list a few example use-cases once interface is finalized. | |
Node is a placeholder name for the data structure that holds the parsed toml. | |
Could be named something else more related to toml? e.g. -> tomlTable | |
*/ | |
/* | |
Receives a channel to a TOML file as a parameter and outputs an associative | |
array Node. | |
*/ | |
proc parseToml(input: channel) : Node {} | |
/* | |
Receives a string of TOML format as a parameter and outputs an associative | |
array Node. | |
*/ | |
proc parseToml(input: string) : Node {} | |
/* | |
Receives an output channel and an instance of Node representing an associative | |
array of the parsed channel. The format for writing into the file is toml. | |
*/ | |
proc writeToml(arr: Node, output: channel) {} | |
I think you can drop function names from docs, and simplify them a bit, e.g.
/*
parseTomlStr takes in a string in toml format to be parsed into an associative
array Node. The Node can be written to a channel using the writeToml procedure.
*/
-->
/*
Parse a string of toml format into an associative array of Nodes.
*/
We'll want to document the Node
class and the public methods as well (since library users will be interacting with it). It may be best to rename Node
to something like TOML
or TomlTable
... This is something that would be helpful to receive feedback on from team / community.
Could we just merge parseToml
and parseTomlStr
into parseToml
with 2 overloads?
I think it'd be useful to include some example uses of the library.
2 examples come to mind:
- Open a toml file (as a channel), parse it, then write it to a file.
- Create a sample string containing toml format, parse it, then rewrite an element in it (e.g. change
name = "sam"
toname = "ben"
), and then write it to stdout.
Open question: Could users call writeln(node)
and rely on the writeThis(f)
of the Node
class to print to the toml contents?
TOML Spec -> https://github.com/toml-lang/toml
URL syntax for restructuredText is:
`Tom's Obvious, Minimal Language (TOML) <https://github.com/toml-lang/toml>`_.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
top-level doc string should be something like: