- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 744
Closed
Labels
jsThis issue relates to better TS-in-JS supportThis issue relates to better TS-in-JS support
Description
- I have checked issues with bug label and found no duplicatesTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Expected Behavior
Generated docs should include only exported functions
Actual Behavior
Generated docs include exported functions plus const
's from require
's
Steps to reproduce the bug
input file
'use strict'
const fs = require('fs')
const os = require('os')
const path = require('path')
const nanoid = require('nanoid')
/**
* Temporary folder
*
* @param {(d: string) => string} transform - Transform function to add prefixes or sufixes to the unique id
* @returns {string} - Full real path to a temporary folder
*/
const tempdir = (transform = d => d) => {
const osTmpDir = fs.realpathSync(os.tmpdir())
return path.join(osTmpDir, transform(nanoid()))
}
module.exports = {
tempdir
}
config
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"target": "es2018",
"moduleResolution": "node",
"resolveJsonModule": true,
"stripInternal": true,
"strict": false,
"alwaysStrict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noEmitOnError": true,
"emitDeclarationOnly": true,
"declaration": true,
"outDir": "types",
"removeComments": true,
"skipLibCheck": true,
"lib": [
"WebWorker.ImportScripts",
"DOM"
]
},
"files": [
"src/temp-dir.js"
],
"exclude": [
"__tests__",
"node_modules",
"types"
],
"typedocOptions": {
"mode": "file",
"out": "docs",
"includeDeclarations": true,
"excludeExternals": true,
"excludeNotExported": true,
"theme": "minimal",
"exclude": [
"**/node_modules/**"
],
"externalPattern":[
"**/node_modules/**"
]
}
}
How can i remove those const in the previous pic ? They are not exported and they are external and still they should up in the docs.
Thank you for your help.
Environment
- Typedoc version: 0.17.3
- Node.js version: 12
- OS: mac os
Metadata
Metadata
Assignees
Labels
jsThis issue relates to better TS-in-JS supportThis issue relates to better TS-in-JS support
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
Gerrit0 commentedon Mar 30, 2020
When you specify this, you tell TS that your files are not modules and everything defined in them is global. File mode should only be used for projects compiled with
tsc --module none
.See #1195.
hugomrdias commentedon Mar 30, 2020
@Gerrit0 didn't help

Managed to remove the require with
excludeNotDocumented
but that is not ideal.From the PR you mentioned seems like another approach i tried before, generate declaration with tsc and feed typedoc the declarations and not the source. This works up to a point because i loose almost all the JSDocs comments not related to types, things like examples, param descriptions etc.
Also with typedoc@next i get
and docs are empty.
Gerrit0 commentedon Mar 30, 2020
Ooh, that's good to know thanks! I thought TypeScript would allow CommonJS style exports to produce a symbol at the source file symbol... That's a bug with library mode then, we need to get module symbols for CommonJS modules some other way.
hugomrdias commentedon Apr 3, 2020
@Gerrit0
mode: 'modules'
still doesnt remove requires usingexcludeNotDocumented
is a workaround and i dont even think this option is documentedGerrit0 commentedon Apr 5, 2020
Looks like you're right! PR welcome if you'd like to fix the docs.
Modules mode should exclude it, but the issue with not being able to get the module symbol in library mode also applies to modules mode.
typedoc/src/lib/converter/factories/declaration.ts
Lines 87 to 98 in c296503
This is an issue that our tests didn't catch since they all use ES modules. Re-opening to track fixing it.
Gerrit0 commentedon Apr 12, 2020
So, I spent a couple hours digging into this. Unfortunately without success...
TS knows that said file is a module, and it knows that it exports stuff, but I can't seem to figure out where to extract this information... I'm beginning to think it isn't exposed anywhere.
You can work around this issue by documenting declaration files instead of the JS source. Not ideal, but...
Gerrit0 commentedon Dec 26, 2020
Apparently TS 4.1 has improved this under the covers - the example file in - 0.20 beta 28 works as expected.