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

Namespaces and Interfaces are not merged. #10

Closed
jackens opened this issue Mar 26, 2022 · 6 comments
Closed

Namespaces and Interfaces are not merged. #10

jackens opened this issue Mar 26, 2022 · 6 comments
Labels
wontfix This will not be worked on

Comments

@jackens
Copy link

jackens commented Mar 26, 2022

package.json:

{
  "devDependencies": {
    "typedoc": "0.22.13",
    "typedoc-plugin-markdown": "3.11.14",
    "typedoc-plugin-merge-modules": "3.1.0",
    "typescript": "4.6.3"
  },
  "name": "issue",
  "type": "module"
}

typedoc.json:

{
  "cleanOutputDir": true,
  "entryPointStrategy": "expand",
  "entryPoints": [
    "src"
  ],
  "gitRevision": "master",
  "hideBreadcrumbs": true,
  "hideInPageTOC": true,
  "hideLegend": true,
  "out": "_doc",
  "readme": "none"
}

tsconfig.json:

{
  "compilerOptions": {
    "allowJs": true,
    "declaration": true,
    "emitDeclarationOnly": true
  },
  "include": [
    "src/**/*.js"
  ]
}

src/file.js:

/**
 * Some module.
 *
 * @module
 */

/**
 * This description is not in the documentation!
 *
 * @callback Type1 This description is not in the documentation!
 *
 * @param {number} one This description is not in the documentation!
 * @param {number} two This description is not in the documentation!
 *
 * @returns {number} This description is not in the documentation!
 */

/**
 * @typedef {{(one: number, two: number) => number}} Type2
 *
 * Some type 2.
 */

/**
 * This block will be placed in the `interfaces/Type3.md` file
 * instead of the `README.md` file.
 *
 * @typedef Type3 Some type 3.
 *
 * @property {number} one property #1
 * @property {number} two property #2
 */

/**
 * @typedef {{
 *   one: number;
 *   two: number;
 * }} Type4
 *
 * Some type 4.
 */

/**
 * Some type 5.
 *
 * This block will be placed in the `modules/Type5.md` file
 * instead of the `README.md` file.
 */
export const Type5 = {}

/**
 * @param {number} n
 *
 * @returns {number}
 */
Type5.id = n => n

Type5.answer = 42

After running

npx typedoc

and

ls -R _doc

we got

README.md       interfaces      modules

_doc/interfaces:
Type3.md

_doc/modules:
Type5.md
@krisztianb
Copy link
Owner

Hi. This plugin merges modules. I haven't used TypeDoc to document JS files yet. Didn't know that works.

I'm a bit confused by your example. Where is your namespace and interface? What would be your expected output?

@krisztianb krisztianb added the under investigation Still figuring out what this is label Mar 27, 2022
@jackens
Copy link
Author

jackens commented Mar 27, 2022

TypeScript works quite well with JavaScript files, and if they have JSDoc blocks in addition, it generates .d.ts files that TypeDoc can turn into quite nice documentation :)

I would expect Type3 to be in README.md, just like Type4 (they're actually the same definitions). Likewise with Type5, which should be merged into README.md.

The plugin should merge the contents of modules and interfaces directories.

@jackens
Copy link
Author

jackens commented Mar 27, 2022

README.md:

# issue

Some module.

## Namespaces

- [Type5](modules/Type5.md)

## Interfaces

- [Type3](interfaces/Type3.md)

## Type aliases

### Type1

Ƭ **Type1**<\>: <\>(`one`: `number`, `two`: `number`) => `number`

#### Type declaration

▸ <\>(`one`, `two`): `number`

##### Parameters

| Name  | Type     |
|:------|:---------|
| `one` | `number` |
| `two` | `number` |

##### Returns

`number`

___

### Type2

Ƭ **Type2**<\>: (`one`: `number`, `two`: `number`) => `number`

#### Type declaration

▸ (`one`, `two`): `number`

Some type 2.

##### Parameters

| Name  | Type     |
|:------|:---------|
| `one` | `number` |
| `two` | `number` |

##### Returns

`number`

#### Defined in

file.js:19

___

### Type4

Ƭ **Type4**<\>: `Object`

Some type 4.

#### Type declaration

| Name  | Type     |
|:------|:---------|
| `one` | `number` |
| `two` | `number` |

#### Defined in

file.js:38

## Variables

### Type5`Const` **Type5**: typeof [`Type5`](README.md#type5) = `{}`

Some type 5.

This block will be placed in the `modules/Type5.md` file
instead of the `README.md` file.

#### Defined in

file.js:49

interfaces/Type3.md:

# Interface: Type3<\>

Some type 3.

## Properties

### one**one**: `number`

property #1

#### Defined in

file.js:30

___

### two**two**: `number`

property #2

#### Defined in

file.js:31

modules/Type5.md:

# Namespace: Type5

## Variables

### answer**answer**: `number`

## Functions

### id**id**(`n`): `number`

#### Parameters

| Name | Type     |
|:-----|:---------|
| `n`  | `number` |

#### Returns

`number`

#### Defined in

file.js:56

@krisztianb
Copy link
Owner

I'm not sure I can follow you there.

This plugin is meant to remove the extra module layer that TypeDoc creates. A module is normally a file which contains something that you want to have documented. The plugin moves all the documented things into the project but doesn't move all documented things into one file which you seem to be looking for here.

@jackens
Copy link
Author

jackens commented Mar 27, 2022

I assumed that the plugin that merges the content of modules should also merge the content of a single module/file (src/file.js from my example). Feel free to close the issue if I am wrong. Thank you for your replies!

@krisztianb
Copy link
Owner

So you want the documentation of several types to be in one file and not one file per type, right? If so then this is not the goal of this plugin.

@jackens jackens closed this as completed Mar 28, 2022
@krisztianb krisztianb added wontfix This will not be worked on and removed under investigation Still figuring out what this is labels Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants