Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
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
The npm package block-documentation receives a total of 1 weekly downloads. As such, block-documentation popularity was classified as not popular.
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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.