Skip to content

Commit f3313c1

Browse files
committed
docs: improve readme [ci skip]
1 parent de85583 commit f3313c1

File tree

1 file changed

+91
-18
lines changed

1 file changed

+91
-18
lines changed

README.md

Lines changed: 91 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,46 @@
22

33
> Develop and demo your Svelte components in your README.md.
44
5-
The purpose of this project is to minimize additional set-up by using the README.md for component documentation and development.
5+
## Readme Driven Development
66

7-
It preprocesses the README.md using [Markdown It](https://github.com/markdown-it/markdown-it) and makes code within `svelte` code fence blocks into runnnable code. The code fence block is preserved and highlighted with [PrismJS](https://github.com/PrismJS/prism).
7+
This project embraces the concept of [Readme Driven Development](https://tom.preston-werner.com/2010/08/23/readme-driven-development.html) (RDD) – or more generally, documentation driven development.
88

9-
[GitHub Markdown CSS](https://github.com/sindresorhus/github-markdown-css) is used for styling.
9+
This module enables the `README.md` to be used for:
10+
11+
- developing a Svelte component
12+
- demoing a Svelte component
13+
- documentation
14+
- installation
15+
- usage
16+
- API
17+
- metadata
18+
- links to Changelog, License etc.
19+
20+
## How it works
21+
22+
At its core, this library is a simple Svelte preprocessor.
23+
24+
1. Use the `svelte` entry defined in your project `package.json`
25+
2. Use `README.md` as the Svelte source code
26+
3. Parse Markdown using [Markdown It](https://github.com/markdown-it/markdown-it)
27+
4. Run code within `svelte` code fence blocks so that demos are juxtaposed with code
28+
29+
[GitHub Markdown CSS](https://github.com/sindresorhus/github-markdown-css) is used for styling to maintain a consistent style with [github.com](https://github.com/).
30+
31+
### Libraries
32+
33+
- [Markdown It](https://github.com/markdown-it/markdown-it)
34+
- [PrismJS](https://github.com/PrismJS/prism)
35+
- [GitHub Markdown CSS](https://github.com/sindresorhus/github-markdown-css)
1036

1137
## Usage
1238

13-
This library is tightly coupled with Rollup. You must provide the package name and svelte entry point.
39+
This library exports two methods:
40+
41+
- `createConfig` (default export): creates a Rollup InputOptions object for you
42+
- `preprocessReadme`: standalone Svelte markup preprocessor
43+
44+
`createConfig` is tightly coupled with Rollup. At a minimum, `package.json#svelte` and `package.json#name` are required.
1445

1546
**package.json**
1647

@@ -24,7 +55,8 @@ This library is tightly coupled with Rollup. You must provide the package name a
2455
"dev": "rollup -cw",
2556
"build": "rollup -c",
2657
"prepack": "BUNDLE=true rollup -c"
27-
}
58+
},
59+
"homepage": "https://github.com/metonym/svelte-readme"
2860
}
2961
```
3062

@@ -40,14 +72,7 @@ import pkg from "./package.json";
4072

4173
export default () => {
4274
if (process.env.BUNDLE !== "true") {
43-
return svelteReadme({
44-
minify: !process.env.ROLLUP_WATCH,
45-
svelte: {
46-
compilerOptions: {
47-
immutable: true,
48-
},
49-
},
50-
});
75+
return svelteReadme();
5176
}
5277

5378
return ["es", "umd"].map((format) => {
@@ -66,11 +91,59 @@ export default () => {
6691
};
6792
```
6893

69-
## Libraries
70-
71-
- [Markdown It](https://github.com/markdown-it/markdown-it)
72-
- [PrismJS](https://github.com/PrismJS/prism)
73-
- [GitHub Markdown CSS](https://github.com/sindresorhus/github-markdown-css)
94+
### API
95+
96+
```ts
97+
interface CreateConfigOptions {
98+
/**
99+
* set to `true` to minify the HTML/JS
100+
* @default false
101+
*/
102+
minify: boolean;
103+
104+
/**
105+
* set the folder to emit the files
106+
* @default "dist"
107+
*/
108+
outDir: string;
109+
110+
/**
111+
* custom CSS appended to the <style> block
112+
* @default ""
113+
*/
114+
style: string;
115+
116+
/**
117+
* set to `true` to omit the default GitHub styles
118+
* @default false
119+
*/
120+
disableDefaultCSS: boolean;
121+
122+
/**
123+
* value to prepend to relative URLs (i.e. GitHub repo URL)
124+
* @default undefined
125+
*/
126+
prefixUrl: string;
127+
128+
/**
129+
* `rollup-plugin-svelte` options
130+
* @default {}
131+
*/
132+
svelte: RollupPluginSvelteOptions;
133+
134+
/**
135+
* Rollup plugins
136+
* @default {[]}
137+
*/
138+
plugins: Plugin[];
139+
140+
/**
141+
* Rollup output options
142+
* @default {{}}
143+
*/
144+
output: OutputOptions;
145+
}
146+
```
74147

75148
## Prior art
76149

0 commit comments

Comments
 (0)