typedoc2md / typedoc-plugin-markdown

A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.
https://typedoc-plugin-markdown.org
MIT License
689 stars 172 forks source link

Parse functions into a table or a list #638

Closed amkuchta closed 2 days ago

amkuchta commented 1 week ago

What package is the feature request related to?

typedoc-plugin-markdown

Background

Currently, lists of functions parse solely into a list format;

Example

/**
 * @function fromJson - The method used to parse a class from a valid JSON string
 * @function toJson - The method used to parse a class to a valid JSON string
 * @function toObject - The method used to parse a class to a generic TypeScript {@linkcode Object}
 * @function validate - The method used to parse a class to a generic TypeScript {@linkcode Object}
 * @function clone - The method used to clone a class to an identical copy of itself
*/

image

Proposed solution

Functions should be able to be parsed into a list similar to how properties are for stylistic consistency

amkuchta commented 1 week ago

It may be worthwhile to extend this to returns values, as well - while only one item may be returned, having it shown in the same tabular format as everything else with a type and description column would be ideal stylistically

tgreyuk commented 1 week ago

Hi - thanks for this.

Functions should be able to be parsed into a list similar to how properties are for stylistic consistency

I'm not too sure how this would work in practice. Incidentally typedoc does not recognize the "@function" tag and attaches no particular meaning to it and will even throw a warning is 0.26.

It doesn't quite address your question, but you could simply write a markdown table in the comments such as:

/*
 * | Function    | Description  |
 * |-------------|-------------------------------------------------------------  |
 * | `fromJson`  | The method used to parse a class from a valid JSON string  |
 * | `toJson`    | The method used to parse a class to a valid JSON string  |
 * | `toObject`  | The method used to parse a class to a generic TypeScript `Object`  |
 * | `validate`  | The method used to parse a class to a generic TypeScript `Object`  |
 * | `clone`     | The method used to clone a class to an identical copy of itself |
 */ 

It may be worthwhile to extend this to returns values, as well - while only one item may be returned, having it shown in the same tabular format as everything else with a type and description column would be ideal stylistically.

Again interesting idea but not too sure how it would work in all scenarios. Functions might have many elements including parameters and type parameters including type and description.

tgreyuk commented 2 days ago

Closing as per above comments.