
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
block-documentation
Advanced tools
Module that reads Typescript interfaces and outputs documentation for backend API's
This module to automatically generate documentation for backend development based on TypeScript interfaces. It uses the Typhen module to scan the interfaces and then parses it into a re-usable json object
Clone the repository and then run:
npm i
To preview output run the following script
npm run example
Fully generate the block documentation include a index.html file to preview the generated output, see the configuration for the available options
Only output the data.json file so you can have your own custom template for displaying generated output, see the configuration for the available options
When running the generate method you can pass along an options:
@placeholder
is provided
The input can be defined in a string
or an object
. If you want to skip the folder input completely you can just define some files that will be scaffolded.
Direct path to folder
{
input: './input/'
}
Direct path to folder with extra files
{
input: {
folder: './input/',
files: [
'./foo/IFooFile.ts',
'./bar/IBarFile.ts',
]
}
}
Only files defined
{
input: {
files: [
'./foo/IFooFile.ts',
'./bar/IBarFile.ts',
]
}
}
All blocks have an interface which describes the data required for the block to provide the data used in the documentation you can use a couple of YUIDoc comments
@placeholder
: This will be used to overwrite the predefined placeholder value@ignore
: If this comment is available it will be skipped@description
: This is the description about the property@defaultValue
: If a default value is present you can provide it with this comment@rawName
: When you use a stringLiteral to type a property you need to define the raw name of the property (see the example interface)Root folder
├── block-foo
│ └── IBlockFooOptions.ts
├── block-bar
│ └── IBlockBarOptions.ts
└── ...
import IImage from "./interface/IImage";
import Theme from "./enum/Theme";
interface IBlockDummyOptions
{
/**
* @ignore
* @description This is the Id of the interface that will be ignored by the generate task
*/
id:string;
/**
* @description The heading displayed
* @defaultValue Define the default value of the property if required
* @placeholder This is a defined placeholder value
*/
header:string;
/**
* @description The image is referenced to another interface
*/
image:IImage
/**
* @description The theme is referenced to an external Enum
*/
theme?:Theme
/**
* @description A forced string value
* @rawName definedString
*/
definedString: "stringValue1" | "stringValue2";
}
export default IBlockDummyOptions
const blockDocumentation = require('block-documentation');
blockDocumentation.generate({
input: {
folder: './input/',
files: [
'./path/to/file.ts'
]
},
output: './output/',
jsonFile: 'data.json',
interfaceName: 'I{blockId}Options.ts',
placeholderValues: {
string: 'Lorem ipsum dolor sit amet',
boolean: true,
number: 1
}
})
FAQs
Module that reads Typescript interfaces and outputs documentation for backend API's
We found that block-documentation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.