Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript module not processed well #272

Open
ovanderzee opened this issue Jan 9, 2022 · 0 comments
Open

Typescript module not processed well #272

ovanderzee opened this issue Jan 9, 2022 · 0 comments

Comments

@ovanderzee
Copy link

Hi, I am using jsdoc-to-markdown version 7.1.0

I am authoring a function library. I started out in vanilla javascript with jsdoc-to-markdown version 6.0.1.
I use jsdoc-to-markdown to present all contained functions without any mutual relationships.
Some functions are grouped in one file, many have their own file. The library itself is a flat iife with all functions.
I can't break that.

I decided to convert the library to typescript and followed the instructions on the wiki about typescript and multiple named exports and entered module names in files with multiple functions. I ended up with garbled output for functions in these files.

I have for example the following module, containing two functions to be used independently:

/**
 * @module mathFunctions
 */

 /**
 * Calculate sum of array with Numbers
 * @param {number[]} seq - array containing numbers
 * @return {number} the sum of the numbers
 */
const mathSum = (seq: number[]): number => seq.reduce((a, b) => a + b, 0)

/**
 * Calculate average of array with Numbers
 * @param {number[]} seq - array containing numbers
 * @return {number} the average of the numbers
 */
const mathAvg = (seq: number[]): number => mathSum(seq) / seq.length || 0

export { mathSum, mathAvg }

When the code is processed mathSum is presented twice:
The first time as static property of the module with the description and parameters of mathAvg.
The second time as a inner method of the module with its own description and parameters.
mathAvg is not mentioned at all.

## mathFunctions

* [mathFunctions](#module_mathFunctions)
    * _static_
        * [.mathSum](#module_mathFunctions.mathSum) ⇒ <code>number</code>
    * _inner_
        * [~mathSum(seq)](#module_mathFunctions..mathSum) ⇒ <code>number</code>

<a name="module_mathFunctions.mathSum"></a>

### mathFunctions.mathSum ⇒ <code>number</code>
<p>Calculate average of array with Numbers</p>

**Kind**: static property of [<code>mathFunctions</code>](#module_mathFunctions)  
**Returns**: <code>number</code> - <p>the average of the numbers</p>  

| Param | Type | Description |
| --- | --- | --- |
| seq | <code>Array.&lt;number&gt;</code> | <p>array containing numbers</p> |

<a name="module_mathFunctions..mathSum"></a>

### mathFunctions~mathSum(seq) ⇒ <code>number</code>
<p>Calculate sum of array with Numbers</p>

**Kind**: inner method of [<code>mathFunctions</code>](#module_mathFunctions)  
**Returns**: <code>number</code> - <p>the sum of the numbers</p>  

| Param | Type | Description |
| --- | --- | --- |
| seq | <code>Array.&lt;number&gt;</code> | <p>array containing numbers</p> |

When I remove the module doc block the information is garbled in the same fashion:

## Members

<dl>
<dt><a href="#mathSum">mathSum</a><code>number</code></dt>
<dd><p>Calculate average of array with Numbers</p></dd>
</dl>

## Functions

<dl>
<dt><a href="#mathSum">mathSum(seq)</a><code>number</code></dt>
<dd><p>Calculate sum of array with Numbers</p></dd>
</dl>

<a name="mathSum"></a>

## mathSum ⇒ <code>number</code>
<p>Calculate average of array with Numbers</p>

**Kind**: global variable  
**Returns**: <code>number</code> - <p>the average of the numbers</p>  

| Param | Type | Description |
| --- | --- | --- |
| seq | <code>Array.&lt;number&gt;</code> | <p>array containing numbers</p> |

<a name="mathSum"></a>

## mathSum(seq) ⇒ <code>number</code>
<p>Calculate sum of array with Numbers</p>

**Kind**: global function  
**Returns**: <code>number</code> - <p>the sum of the numbers</p>  

| Param | Type | Description |
| --- | --- | --- |
| seq | <code>Array.&lt;number&gt;</code> | <p>array containing numbers</p> |

Ideally I would like to see the functions presented without any relationships. Like how it was with version 6.0.1 and before converting to typescript. The module name is not important to the consumer of this library.
But the main thing is of course to present the two functions. I don't want to edit the file after processing.

jsdoc2md.json:

{
    "source": {
        "includePattern": ".+\\.ts(doc|x)?$",
        "excludePattern": ".+\\.(test|spec).(ts|js)"
    },
    "plugins": [
        "plugins/markdown",
        "node_modules/jsdoc-babel"
    ],
    "babel": {
        "extensions": ["ts", "tsx"],
        "ignore": ["**/*.(test|spec).(ts|js)"],
        "babelrc": false,
        "presets": [["@babel/preset-env", { "targets": "> 0.25%, not dead" }], "@babel/preset-typescript"],
        "plugins": ["@babel/proposal-class-properties", "@babel/proposal-object-rest-spread"]
    }
}

command:

    "postbuild": "jsdoc2md --files src/**/*.ts --configure ./jsdoc2md.json > API.md",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant