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

Unexported variables are not removed #1195

Closed
1 task done
njh7799 opened this issue Jan 29, 2020 · 2 comments
Closed
1 task done

Unexported variables are not removed #1195

njh7799 opened this issue Jan 29, 2020 · 2 comments
Labels
no bug This is expected behavior

Comments

@njh7799
Copy link

njh7799 commented Jan 29, 2020

Expected Behavior

Not exported variables are not removed

Here's my code.

// typedoc.json
{
  "name": "Orion-facebook",
  "inputFiles": ["./src"],
  "mode": "file",
  "out": "docs",
  "excludeNotExported": true,
  "excludePrivate": true
}
// my code
...
const getPageData = async (date: string, from: string) => {
  return await ...;
};

const findRow = ($, to: string) => {
  const row = ...;
  return row;
};

const findCurrencyRate = ($, row) => {
  let currencyRate;
  ...
  return currencyRate;
};

const getCurrencyRate = async (date: string, from: string, to: string) => {
  const response = await getPageData(date, from);
  const html = response.data;
  const $ = cheerio.load(html);
  const row = findRow($, to);
  const currencyRate = findCurrencyRate($, row);
  return currencyRate;
};

const getNothing = async () => {};

export default getCurrencyRate;

I thought only getCurrencyRate would be generated at doc files since I'd set excludeNotExported to be true. However, the result was shown as below. The other non exported variables are not removed.

Actual Behavior

image

Steps to reproduce the bug

Environment

  • Typedoc version:0.16.9
  • Node.js version:12.14.0
  • OS:mac
@njh7799 njh7799 added the bug Functionality does not match expectation label Jan 29, 2020
@xshkut
Copy link

xshkut commented Jan 30, 2020

I have the same problem. As temporary workaround you can tag your functions as @internal like

/**@internal */
const findRow = ($, to: string) => {
const row = ...;  
return row;  
};

Also --excludeNotExported works well with --mode modules, but it can affect your classes (change them to external modules and wrap them in double quotes)

@njh7799 njh7799 changed the title Not exported variables are not removed Unexported variables are not removed Jan 31, 2020
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jan 31, 2020

With --mode file this is expected behavior.

File mode tells TypeDoc that your source files should be treated as global script files, all declarations in them are implicitly exported.

You might be interested in the upcoming library mode, #1184, where TypeDoc builds documentation for only those declarations exported from the input file. You can try it out by installing typedoc@next and changing your typedoc.json file to be:

{
  "name": "Orion-facebook",
  "inputFiles": ["./src/index.ts"], // Note that this specifies a single file, since otherwise all files are treated as entry points.
  "mode": "library",
  "out": "docs",
  "excludeNotExported": true, // Doesn't do anything in library mode
  "excludePrivate": true
}

@Gerrit0 Gerrit0 added no bug This is expected behavior and removed bug Functionality does not match expectation labels Feb 26, 2020
@Gerrit0 Gerrit0 closed this as completed Mar 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no bug This is expected behavior
Projects
None yet
Development

No branches or pull requests

3 participants