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

How to Merge namespace in difference Files? #1424

Closed
arvinxx opened this issue Dec 29, 2020 · 10 comments
Closed

How to Merge namespace in difference Files? #1424

arvinxx opened this issue Dec 29, 2020 · 10 comments
Labels
question Question about functionality

Comments

@arvinxx
Copy link

arvinxx commented Dec 29, 2020

I have a files like this

image

All of them are start with

declare namespace chromeExtension {
    // ...
}

when I use typedoc to generate docs, the result is below:

image

image

How can I merge this namespace into one file ?

my typedoc version is 0.19.2 and use the typedoc-plugin-external-module-map plugin

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 29, 2020

In 0.19, the way to do this is to use --mode file. In 0.20, I don't think there's a really good way to do this... you might be able to point typedoc at the index.d.ts file (assuming it /// <reference />s the other files)

@arvinxx
Copy link
Author

arvinxx commented Dec 29, 2020

In 0.19, the way to do this is to use --mode file. In 0.20, I don't think there's a really good way to do this... you might be able to point typedoc at the index.d.ts file (assuming it /// <reference />s the other files)

Thanks, it work well! And I can use 0.19.2 by now. But I wonder in 0.20, is there anyway to handle this in some easy way? (I have the /// <reference /> index.d.ts file)

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 29, 2020

0.20.3 now works better with global files, you should be able to get good results with:

npx typedoc types/Manifest/index.d.ts

@Gerrit0 Gerrit0 added the question Question about functionality label Dec 29, 2020
@arvinxx
Copy link
Author

arvinxx commented Dec 30, 2020

I update the typedoc version and try your command but failed.Is there something I has configured wrong?

my typedoc config file:

const isProdSite = process.env.NODE_ENV === 'production';

module.exports = {
  name: 'umi-plugin-extensions',
  tsconfig: './tsconfig-typedoc.json',
  entryPoints: ['types/index.d.ts'],
  out: 'document/docs/api',
  exclude: ['**/node_modules/**'],
  excludePrivate: true,
  excludeProtected: true,
  excludeExternals: true,
  includeVersion: true,
  disableSources: true,
  readme: 'document/API.md',
  plugin: [
    'typedoc-plugin-markdown',
  ],
  hideBreadcrumbs: true,
  namedAnchors: true,
  hideProjectName: true,
  publicPath: isProdSite ? '/umi-plugin-extensions/api/' : '/api/',
};

my tsconfig file:

{
  "include": ["types"],
  "compilerOptions": {
    "target": "ESNext",
    "moduleResolution": "node",
    "allowJs": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "noEmitOnError": false,
    "noStrictGenericChecks": true,
    "skipLibCheck": true,
    "declaration": true
  },
  "exclude": [
    "node_modules",
    "dist",
    "**/*.spec.ts",
    "lib",
    "src/.umi/**",
    "fixtures",
    "examples"
  ]
}

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 30, 2020

There have been some changes to the option names - https://github.com/TypeStrong/typedoc/releases/tag/v0.20.0

typedoc-plugin-markdown will also need an update, 3.2.1 I believe

@arvinxx
Copy link
Author

arvinxx commented Dec 30, 2020

There have been some changes to the option names - https://github.com/TypeStrong/typedoc/releases/tag/v0.20.0

typedoc-plugin-markdown will also need an update, 3.2.1 I believe

yeah I have changed the config like entryPoints. And also update the markdown plugin version.

The result I get is a modules.md files without modules I expect.

@arvinxx
Copy link
Author

arvinxx commented Dec 30, 2020

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 30, 2020

Ah, that's why, /// references aren't really exports, so typedoc doesn't know to document their contents. If you add declare namespace chromeManifest {} (or equivalent for each namespace) in your entry point, then it will pick it up as a global declared in that file and document it.

@arvinxx
Copy link
Author

arvinxx commented Dec 30, 2020

a strange generate behavior, when use two entryPoints like below:

  entryPoints: [
    'types/chromeManifest/index.d.ts',
    'types/extensionsPlugin/index.d.ts',
  ],

the result is:
image

when using one entryPoint,the result is right

image

Is there something wrong?

More Info:

if I add both namespace chromeManifest and extensionsPlugin in the root index.d.ts

./types
---manifest
---extensionsplugin
---index.d.ts

the root index.d.ts file:

declare namespace chromeManifest {}

declare namespace extensionsPlugin {}

the result is right.

image

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 30, 2020

Typedoc has special casing if there is only one entry point to avoid nesting the documentation within a module and directly including the module members within the project.

With two entry points, we can't do this since a user needs to be able to tell what module the exports are from... "global" modules aren't commonly used anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about functionality
Projects
None yet
Development

No branches or pull requests

2 participants