Skip to content

Commit

Permalink
feat: automatically get the package name and description
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Mar 23, 2020
1 parent 0a24d85 commit e335483
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 25 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@

<!-- START-PACKAGE-SECTION -->

## @component-controls/instrument
## [@component-controls/instrument](https://github.com/ccontrols/component-controls/blob/master/core/instrument)

Component controls instrumentation library

Component controls instrumentation library.
Parsing a source file will generate the following information:

- CSF: List of story named exports
Expand All @@ -39,9 +40,9 @@ Parsing a source file will generate the following information:

<!-- START-PACKAGE-SECTION -->

## @component-controls/components
## [@component-controls/components](https://github.com/ccontrols/component-controls/blob/master/ui/components)

A collection of commonly used UI components for component-controls
Component controls commonly used UI components.

Some of the guiding design goals for this library:

Expand All @@ -67,9 +68,9 @@ Third-libraries used in no particular order:

<!-- START-PACKAGE-SECTION -->

## @component-controls/editors
## [@component-controls/editors](https://github.com/ccontrols/component-controls/blob/master/core/specification)

A collection of editors used to edit component control values.
Component controls editors for component control values.

Some of the guiding design goals for this library:

Expand All @@ -82,9 +83,9 @@ Some of the guiding design goals for this library:

<!-- START-PACKAGE-SECTION -->

## @component-controls/blocks
## [@component-controls/blocks](https://github.com/ccontrols/component-controls/blob/master/ui/blocks)

A collection of core block components - intended to be displayed on the documentation page of stories.
Component controls core documentation blocks.

Some of the guiding design goals for this library:

Expand Down
3 changes: 0 additions & 3 deletions core/instrument/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Overview

## @component-controls/instrument

Component controls instrumentation library.
Parsing a source file will generate the following information:
- CSF: List of story named exports
- CSF: Default export stories file information
Expand Down
24 changes: 24 additions & 0 deletions scripts/insert-overview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const fs = require('fs');
const path = require('path');
const remark = require('remark');
const { extractCustomTag, inlineNewContent } = require('./utils');

Expand All @@ -15,6 +16,29 @@ function insertOverview(options) {
const sectionName = sectionAttr ? sectionAttr[1].toLowerCase() : 'overview';
const content = fs.readFileSync(file[1], 'utf8');
const overviewNodes = [];
const packageJSONFilename = path.resolve(path.join(path.dirname(file[1]), 'package.json'));
if (fs.existsSync(packageJSONFilename)) {
const packageJSON = JSON.parse(fs.readFileSync(packageJSONFilename));

const { name, description, repository: { directory }} = packageJSON;
const rootRepoDir = `https://github.com/ccontrols/component-controls/blob/master/${directory}`;
overviewNodes.push({
type: 'heading',
depth: 2,
children: [
{ type: 'link', url: rootRepoDir, children: [
{ type: 'text', value: name}
]}
]
});
overviewNodes.push({
type: 'paragraph',
children: [
{ type: 'text', value: description}
]
});

}
remark()
.use(() => sectionNode => {
let foundDepth = 0;
Expand Down
4 changes: 0 additions & 4 deletions ui/blocks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@

# Overview

## @component-controls/blocks

A collection of core block components - intended to be displayed on the documentation page of stories.

Some of the guiding design goals for this library:

- Most components should have a 'plain' and a 'block' version, where the block version adds a collapsible Box with a title.
Expand Down
2 changes: 1 addition & 1 deletion ui/blocks/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@component-controls/blocks",
"version": "0.6.0",
"description": "Core blocks component controls",
"description": "Component controls core documentation blocks.",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"typings": "dist/index.d.ts",
Expand Down
3 changes: 0 additions & 3 deletions ui/components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@

# Overview

## @component-controls/components

A collection of commonly used UI components for component-controls

Some of the guiding design goals for this library:

Expand Down
2 changes: 1 addition & 1 deletion ui/components/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@component-controls/components",
"version": "0.6.0",
"description": "Component controls user interface components",
"description": "Component controls commonly used UI components.",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"typings": "dist/index.d.ts",
Expand Down
4 changes: 0 additions & 4 deletions ui/editors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@

# Overview

## @component-controls/editors

A collection of editors used to edit component control values.

Some of the guiding design goals for this library:

- Extensible using `addPropertyEditor`, so you can replace or add new editors.
Expand Down
2 changes: 1 addition & 1 deletion ui/editors/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@component-controls/editors",
"version": "0.6.0",
"description": "Component controls specification and utility routines",
"description": "Component controls editors for component control values.",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"typings": "dist/index.d.ts",
Expand Down

0 comments on commit e335483

Please sign in to comment.