Skip to content

Commit

Permalink
Use typedoc for documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan818fr committed Oct 13, 2021
1 parent 2618f7c commit 1e2e56d
Show file tree
Hide file tree
Showing 20 changed files with 2,745 additions and 152 deletions.
96 changes: 4 additions & 92 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,95 +42,7 @@ javaProps

## Documentation

<!-- jsdoc2md start -->

- [javaProps](#javaProps)
- [.parse(str)](#javaProps.parse) ⇒ <code>Object</code>
- [.parseFile(path, [encoding])](#javaProps.parseFile) ⇒ <code>Promise.&lt;Object&gt;</code>
- [.stringify(props)](#javaProps.stringify) ⇒ <code>String</code>

<a name="javaProps.parse"></a>

### javaProps.parse(str) ⇒ <code>Object</code>

Parses a .properties string, constructing a corresponding JavaScript object.

**Returns**: <code>Object</code> - The [Object](Object) corresponding to the given string

| Param | Type | Description |
| ----- | ------------------- | ---------------------------------- |
| str | <code>String</code> | The string to parse as .properties |

**Example**

```js
const props = javaProps.parse('foo=Hello\nbar=World');
console.log(props.foo + ' ' + props.bar);
// "Hello World"
```

<a name="javaProps.parseFile"></a>

### javaProps.parseFile(path, [encoding]) ⇒ <code>Promise.&lt;Object&gt;</code>

Parses a .properties file, constructing a corresponding JavaScript object.

**Returns**: <code>Promise.&lt;Object&gt;</code> - The [Object](Object) corresponding to the given string

| Param | Type | Default | Description |
| ---------- | ------------------------------------------------------------------------------------- | ----------------- | --------------------------- |
| path | <code>String</code> \| <code>Buffer</code> \| <code>URL</code> \| <code>number</code> | | Filename or file descriptor |
| [encoding] | <code>String</code> | <code>utf8</code> | File encoding |

**Example**

```js
javaProps
.parseFile('./foobar.properties')
.then((props) => {
console.log(props.foo + ' ' + props.bar);
// "Hello World"
})
.catch((err) => {
console.error(err);
});
```

_- or with async/await -_

```js
async function fct() {
try {
const props = await javaProps.parseFile('./foobar.properties');
console.log(props.foo + ' ' + props.bar);
// "Hello World"
} catch (err) {
console.error(err);
}
}
```

<a name="javaProps.stringify"></a>

### javaProps.stringify(props) ⇒ <code>String</code>

Convert a JavaScript object to the corresponding .properties string.

**Returns**: <code>String</code> - The .properties string corresponding to the given JavaScript object

| Param | Type | Description |
| ----- | ------------------- | -------------------------------- |
| props | <code>Object</code> | The JavaScript object to convert |

**Example**

```js
const str = javaProps.stringify({foo: 'Hello', bar: 'World'});
console.log(str);
// "foo: Hello\nbar: World\n"
```

<!-- jsdoc2md end -->
For detailed API Documentation, see: [https://nathan818fr.github.io/node-java-props/modules.html](https://nathan818fr.github.io/node-java-props/modules.html)

## Building

Expand All @@ -140,11 +52,11 @@ This project uses TypeScript. To create javascript sources run:
yarn run build
```

To generate the documentation, edit `documentation.js` then run:
To generate the documentation, use typedoc:

```sh
# npm install -g jsdoc-to-markdown
jsdoc2md --partial doc/scope.hbs --files doc/documentation.js --heading-depth 3 | xclip -selection c
npm install -g typedoc
typedoc
```

and copy the result inside this README.
Expand Down
60 changes: 0 additions & 60 deletions doc/documentation.js

This file was deleted.

Empty file removed doc/scope.hbs
Empty file.
1 change: 1 addition & 0 deletions docs/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
85 changes: 85 additions & 0 deletions docs/assets/highlight.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
:root {
--light-hl-0: #0000FF;
--dark-hl-0: #569CD6;
--light-hl-1: #000000;
--dark-hl-1: #D4D4D4;
--light-hl-2: #0070C1;
--dark-hl-2: #4FC1FF;
--light-hl-3: #001080;
--dark-hl-3: #9CDCFE;
--light-hl-4: #795E26;
--dark-hl-4: #DCDCAA;
--light-hl-5: #A31515;
--dark-hl-5: #CE9178;
--light-hl-6: #EE0000;
--dark-hl-6: #D7BA7D;
--light-hl-7: #008000;
--dark-hl-7: #6A9955;
--light-hl-8: #AF00DB;
--dark-hl-8: #C586C0;
--light-code-background: #FFFFFF;
--dark-code-background: #1E1E1E;
}

@media (prefers-color-scheme: light) { :root {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--code-background: var(--light-code-background);
} }

@media (prefers-color-scheme: dark) { :root {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--code-background: var(--dark-code-background);
} }

body.light {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--code-background: var(--light-code-background);
}

body.dark {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--code-background: var(--dark-code-background);
}

.hl-0 { color: var(--hl-0); }
.hl-1 { color: var(--hl-1); }
.hl-2 { color: var(--hl-2); }
.hl-3 { color: var(--hl-3); }
.hl-4 { color: var(--hl-4); }
.hl-5 { color: var(--hl-5); }
.hl-6 { color: var(--hl-6); }
.hl-7 { color: var(--hl-7); }
.hl-8 { color: var(--hl-8); }
pre, code { background: var(--code-background); }
Loading

0 comments on commit 1e2e56d

Please sign in to comment.