7.0.0 • Published 1 year ago

@charlietango/react-docs-net v7.0.0

Weekly downloads
138
License
MIT
Repository
-
Last release
1 year ago

React Docs Net

Take the JSON output from react-docgen, and convert it to C# ViewModels for consumption in .NET projects. Why would you do this? It allows us to define the ViewModels in the Frontend where we actually use them.

⚠️ Warning

This is a basic rewrite of the React props to C#/.NET. No validation is done on the actual files. Not all Flow features are supported, since there's not a simple way to convert them to C#.

  • All models are converted to upper camelcase, with ViewModel appendend.
  • Enum models are converted to upper camelcase, with Types appended
  • Flow number is converted to int. Use @type {TYPE} in comment tag for the prop, to change the number type.

Requirements

  • Node 8.x+
  • Flow Currently only supports extracting models from Flow Types.
  • react-docgen JSON files

Usage

Add the dependency

yarn add @charlietango/react-docs-net --dev

Generate JSON files with react-docgen, and process them:

const docNet = require('@charlietango/react-docs-net');

docNet.createModels([{name: 'CustomModel', docs: {...}}], {
  namespace: 'Dk.CharlieTango',
  dest: 'dist/models', // Add dest to write to files
});

or calling the bin

$ react-doc-net src/models/**/*.json --ns Dk.CharlieTango --dest dist/models

The .cs view models will be created in dist/models.

Config

NameTypeDefaultDescription
namespacestringNamespace to use in all the models
deststringWrite .cs files to the this path
verbosebooleanfalseOutput extra logging
quietbooleanfalseDon't output anything to log

JSDoc flags

You can use these flags in JS comments to modify how a prop is handled.

  • @internal - Ignore this prop - It's only used internally in the React App.
  • @type - Set a specific C# type for this prop - Like decimal
  • @static - Marks classes or fields as static.
  • @generic - Should always be put above a generic prop
  • @genericTypes T: Enum - Optional. Should be placed before the current type definition
7.0.0

1 year ago

6.2.2

1 year ago

6.2.0

2 years ago

6.1.1

3 years ago

6.1.0

3 years ago

6.0.0

3 years ago

6.0.3

3 years ago

6.0.2

3 years ago

5.4.5

3 years ago

5.4.3

3 years ago

5.4.2

4 years ago

5.4.1

4 years ago

5.4.0

4 years ago

5.3.1

4 years ago

5.3.0

4 years ago

5.2.0

4 years ago

5.1.2

4 years ago

5.1.0

4 years ago

5.0.0

4 years ago

4.1.4

5 years ago

4.1.2

5 years ago

4.1.1

5 years ago

4.1.0

5 years ago

4.0.0

5 years ago

3.5.3

5 years ago

3.5.2

5 years ago

3.5.1

5 years ago

3.5.0

5 years ago

3.4.1

5 years ago

3.4.0

5 years ago

3.3.0

5 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.2

6 years ago

3.0.0

6 years ago

2.5.0

6 years ago

2.4.1

6 years ago

2.4.0

6 years ago

2.3.3

6 years ago

2.3.2

6 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.0

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.4.0

6 years ago

1.3.3

6 years ago

1.1.18

6 years ago

1.1.13

6 years ago

1.1.12

6 years ago

1.1.11

6 years ago

1.1.10

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.1

6 years ago