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

Weird file naming when export= #761

Open
Sytten opened this issue Jan 15, 2025 · 0 comments
Open

Weird file naming when export= #761

Sytten opened this issue Jan 15, 2025 · 0 comments
Labels
bug Issue raised as a bug.

Comments

@Sytten
Copy link

Sytten commented Jan 15, 2025

What package is the bug related to?

typedoc-plugin-markdown

Describe the issue

Given the typescript:

/**
 * The `path` module provides utilities for working with file and directory
 * paths. It can be accessed using:
 *
 * ```js
 * import path from 'path';
 * ```
 */
declare module "path" {
  namespace path {
    /**
     * A parsed path object generated by path.parse() or consumed by path.format().
     */
    interface ParsedPath {
      /**
       * The root of the path such as '/' or 'c:\'
       */
      root: string;
      /**
       * The full directory path such as '/home/user/dir' or 'c:\path\dir'
       */
      dir: string;
      /**
       * The file name including extension (if any) such as 'index.html'
       */
      base: string;
      /**
       * The file extension (if any) such as '.html'
       */
      ext: string;
      /**
       * The file name without extension (if any) such as 'index'
       */
      name: string;
    }
    interface FormatInputPathObject {
      /**
       * The root of the path such as '/' or 'c:\'
       */
      root?: string | undefined;
      /**
       * The full directory path such as '/home/user/dir' or 'c:\path\dir'
       */
      dir?: string | undefined;
      /**
       * The file name including extension (if any) such as 'index.html'
       */
      base?: string | undefined;
      /**
       * The file extension (if any) such as '.html'
       */
      ext?: string | undefined;
      /**
       * The file name without extension (if any) such as 'index'
       */
      name?: string | undefined;
    }
    interface PlatformPath {
      /**
       * Normalize a string path, reducing '..' and '.' parts.
       * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
       *
       * @param path string path to normalize.
       * @throws {TypeError} if `path` is not a string.
       */
      normalize(path: string): string;
      /**
       * Join all arguments together and normalize the resulting path.
       *
       * @param paths paths to join.
       * @throws {TypeError} if any of the path segments is not a string.
       */
      join(...paths: string[]): string;
      /**
       * The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
       *
       * Starting from leftmost {from} parameter, resolves {to} to an absolute path.
       *
       * If {to} isn't already absolute, {from} arguments are prepended in right to left order,
       * until an absolute path is found. If after using all {from} paths still no absolute path is found,
       * the current working directory is used as well. The resulting path is normalized,
       * and trailing slashes are removed unless the path gets resolved to the root directory.
       *
       * @param paths A sequence of paths or path segments.
       * @throws {TypeError} if any of the arguments is not a string.
       */
      resolve(...paths: string[]): string;
      /**
       * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
       *
       * If the given {path} is a zero-length string, `false` will be returned.
       *
       * @param path path to test.
       */
      isAbsolute(path: string): boolean;
      /**
       * Return the directory name of a path. Similar to the Unix dirname command.
       *
       * @param path the path to evaluate.
       */
      dirname(path: string): string;
      /**
       * Return the last portion of a path. Similar to the Unix basename command.
       * Often used to extract the file name from a fully qualified path.
       *
       * @param path the path to evaluate.
       * @param suffix optionally, an extension to remove from the result.
       */
      basename(path: string, suffix?: string): string;
      /**
       * Return the extension of the path, from the last '.' to end of string in the last portion of the path.
       * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string.
       *
       * @param path the path to evaluate.
       */
      extname(path: string): string;
      /**
       * The platform-specific file separator. '\\' or '/'.
       */
      readonly sep: "\\" | "/";
      /**
       * The platform-specific file delimiter. ';' or ':'.
       */
      readonly delimiter: ";" | ":";
      /**
       * Returns an object from a path string - the opposite of format().
       *
       * @param path path to evaluate.
       * @throws {TypeError} if `path` is not a string.
       */
      parse(path: string): ParsedPath;
      /**
       * Returns a path string from an object - the opposite of parse().
       *
       * @param pathObject path to evaluate.
       */
      format(pathObject: FormatInputPathObject): string;
    }
  }
  const path: path.PlatformPath;
  export = path;
}

It generates a file called export=.md.

Screenshot 2025-01-15 at 10 55 48 AM
[@caido/quickjs-types](../../index.md) / llrt/path

# llrt/path

## Namespaces

| Namespace | Description |
| ------ | ------ |
| [export=](namespaces/export=.md) | - |

## Variables

### export=

> **export=**: [`PlatformPath`](namespaces/export=.md#platformpath)

## References

### FormatInputPathObject

Re-exports [FormatInputPathObject](namespaces/export=.md#formatinputpathobject)

### ParsedPath

Re-exports [ParsedPath](namespaces/export=.md#parsedpath)

### PlatformPath

Re-exports [PlatformPath](namespaces/export=.md#platformpath)
[@caido/quickjs-types](../../../index.md) / [llrt/path](../index.md) / export=

# export=

## Interfaces

### FormatInputPathObject

#### Properties

##### base?

> `optional` **base**: `string`

The file name including extension (if any) such as 'index.html'

##### dir?

> `optional` **dir**: `string`

The full directory path such as '/home/user/dir' or 'c:\path\dir'

##### ext?

> `optional` **ext**: `string`

The file extension (if any) such as '.html'

##### name?

> `optional` **name**: `string`

The file name without extension (if any) such as 'index'

##### root?

> `optional` **root**: `string`

The root of the path such as '/' or 'c:\'

***

### ParsedPath

A parsed path object generated by path.parse() or consumed by path.format().

#### Properties

##### base

> **base**: `string`

The file name including extension (if any) such as 'index.html'

##### dir

> **dir**: `string`

The full directory path such as '/home/user/dir' or 'c:\path\dir'

##### ext

> **ext**: `string`

The file extension (if any) such as '.html'

##### name

> **name**: `string`

The file name without extension (if any) such as 'index'

##### root

> **root**: `string`

The root of the path such as '/' or 'c:\'

***

### PlatformPath

#### Properties

##### delimiter

> `readonly` **delimiter**: `";"` \| `":"`

The platform-specific file delimiter. ';' or ':'.

##### sep

> `readonly` **sep**: "\\" \| `"/"`

The platform-specific file separator. '\\' or '/'.

#### Methods

##### basename()

> **basename**(`path`: `string`, `suffix`?: `string`): `string`

Return the last portion of a path. Similar to the Unix basename command.
Often used to extract the file name from a fully qualified path.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `path` | `string` | the path to evaluate. |
| `suffix`? | `string` | optionally, an extension to remove from the result. |

###### Returns

`string`

##### dirname()

> **dirname**(`path`: `string`): `string`

Return the directory name of a path. Similar to the Unix dirname command.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `path` | `string` | the path to evaluate. |

###### Returns

`string`

##### extname()

> **extname**(`path`: `string`): `string`

Return the extension of the path, from the last '.' to end of string in the last portion of the path.
If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `path` | `string` | the path to evaluate. |

###### Returns

`string`

##### format()

> **format**(`pathObject`: [`FormatInputPathObject`](export=.md#formatinputpathobject)): `string`

Returns a path string from an object - the opposite of parse().

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `pathObject` | [`FormatInputPathObject`](export=.md#formatinputpathobject) | path to evaluate. |

###### Returns

`string`

##### isAbsolute()

> **isAbsolute**(`path`: `string`): `boolean`

Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.

If the given {path} is a zero-length string, `false` will be returned.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `path` | `string` | path to test. |

###### Returns

`boolean`

##### join()

> **join**(...`paths`: `string`[]): `string`

Join all arguments together and normalize the resulting path.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| ...`paths` | `string`[] | paths to join. |

###### Returns

`string`

###### Throws

if any of the path segments is not a string.

##### normalize()

> **normalize**(`path`: `string`): `string`

Normalize a string path, reducing '..' and '.' parts.
When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `path` | `string` | string path to normalize. |

###### Returns

`string`

###### Throws

if `path` is not a string.

##### parse()

> **parse**(`path`: `string`): [`ParsedPath`](export=.md#parsedpath)

Returns an object from a path string - the opposite of format().

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `path` | `string` | path to evaluate. |

###### Returns

[`ParsedPath`](export=.md#parsedpath)

###### Throws

if `path` is not a string.

##### resolve()

> **resolve**(...`paths`: `string`[]): `string`

The right-most parameter is considered {to}. Other parameters are considered an array of {from}.

Starting from leftmost {from} parameter, resolves {to} to an absolute path.

If {to} isn't already absolute, {from} arguments are prepended in right to left order,
until an absolute path is found. If after using all {from} paths still no absolute path is found,
the current working directory is used as well. The resulting path is normalized,
and trailing slashes are removed unless the path gets resolved to the root directory.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| ...`paths` | `string`[] | A sequence of paths or path segments. |

###### Returns

`string`

###### Throws

if any of the arguments is not a string.

TypeDoc configuration

{
  "plugin": [
    "typedoc-plugin-markdown",
    "typedoc-plugin-missing-exports",
  ],
  "cleanOutputDir": true,
  "outputFileStrategy": "modules",
  "entryFileName": "index",
  "readme": "none",
  "disableSources": true,
  "excludeExternals": true,
  "placeInternalsInOwningModule": true,
  "hidePageHeader": true,
  "expandParameters": true,
  "parametersFormat": "table",
  "indexFormat": "table",
  "entryPoints": [
      "src/llrt/path.d.ts",
    ],
    "externalPattern": ["**/node_modules/typescript/**"],
}

Expected behavior

Ideally something with a better name? I don't know if there is a way to flatten that out to remove the namespace.
Happy to write a plugin to handle that but there are not that many example of plugins.
This typing is very close to the way Node .d.ts is written, so really something common enough in the ecosystem.

@Sytten Sytten added the bug Issue raised as a bug. label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue raised as a bug.
Projects
None yet
Development

No branches or pull requests

1 participant