Skip to content

Instantly share code, notes, and snippets.

@gjtorikian
Created February 12, 2012 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gjtorikian/1809799 to your computer and use it in GitHub Desktop.
Save gjtorikian/1809799 to your computer and use it in GitHub Desktop.
API Markdown styles
## readFileSync(filename, [encoding])
* `filename` String, Required. The name of the file to read
* `encoding` String, Optional. The encoding to use
* Returns: String or Buffer. The contents of the filename. If `encoding` is specified, then this function returns a string. Otherwise it returns a `buffer`.
* * *
## fs.readFileSync(filename, [encoding='utf8']) -> String | Buffer
- filename (String): The name of the file to read
- encoding (String): The encoding to use
#### Returns
The contents of the `filename`. If `encoding` is specified, then this function returns a string. Otherwise it returns a [[buffer buffer]].
* * *
## fs.writeFile(filename, data, [encoding], [callback]) -> Void
- filename String. The name of the file to write to
- data String or buffer, default is 'utf8'. The data to write (this can be a string or a buffer)
- encoding String. The encoding to use (this is ignored if `data` is a buffer)
- callback Function. An optional callback to execute once the function completes
fs.writeFile(filename, data, [encoding='utf8'], [callback()]) -> Void
- filename (String): The name of the file to write to
- data (String | buffer): The data to write (this can be a string or a buffer)
- encoding (String): The encoding to use (this is ignored if `data` is a buffer)
- callback (Function): An optional callback to execute once the function completes
@isaacs
Copy link

isaacs commented Feb 14, 2012

Another option:

## fs.writeFile(filename, data, [encoding = 'utf8'], [callback])
* filename {String} The name of the file to write to
* data {String | Buffer} The data to write (this can be a string or a buffer)
* encoding {String} The encoding to use (this is ignored if `data` is a buffer)
* callback {Function}  An optional callback to execute once the function completes

Another open question: how should we express the arguments passed to a callback? It's not quite a return or throws, but sort of similar.

@gjtorikian
Copy link
Author

I think at one point you indented the args into another ul, no?

## fs.writeFile(filename, data, [encoding = 'utf8'], [callback])
* filename {String} The name of the file to write to
* data {String | Buffer} The data to write (this can be a string or a buffer)
* encoding {String} The encoding to use (this is ignored if `data` is a buffer)
* callback {Function}  An optional callback to execute once the function completes
  * err {Error} The standard error object

Ideally the parser,when rendering the HTML, will plug in the child UL back into the signature: fs.writeFile(filename, data, [encoding = 'utf8'], [callback(err)]).

@isaacs
Copy link

isaacs commented Feb 14, 2012

I hadn't suggested indenting the args into a child UL, no, but that's a good idea. The trick then would be for us to perhaps just treat a child list differently based on the type of the parent.

parent is a... >>  list is...
event >> arguments
function >> arguments (and return?)
object >> child fields

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment