Skip to content

Commit

Permalink
change code to improve API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mizdra committed Jul 2, 2023
1 parent b5e9c26 commit b3e4e79
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 27 deletions.
6 changes: 5 additions & 1 deletion docs/api/inline-fixture-files.createiff.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## createIFF() function

Create fixtures in the specified directory. The path separator must be in POSIX format (`/`<!-- -->). Use of Windows path separator is an undefined behavior.
Create fixtures in the specified directory.

**Signature:**

Expand All @@ -25,6 +25,10 @@ Promise&lt;[CreateIFFResult](./inline-fixture-files.createiffresult.md)<!-- -->&

An object that provides functions to manipulate the fixtures.

## Remarks

The path must be in POSIX-style (`'dir/file.txt'`<!-- -->). Use of Windows-style path (`'dir\\file.txt'`<!-- -->) is an undefined behavior.

## Example


Expand Down
4 changes: 2 additions & 2 deletions docs/api/inline-fixture-files.createiffresult.addfixtures.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## CreateIFFResult.addFixtures() method

Add fixtures to `rootDir`<!-- -->.
Add fixtures to [rootDir](./inline-fixture-files.createiffoptions.rootdir.md)<!-- -->.

**Signature:**

Expand All @@ -22,5 +22,5 @@ addFixtures<const U extends Directory>(additionalDirectory: U): Promise<AddFixtu
Promise&lt;[AddFixturesResult](./inline-fixture-files.addfixturesresult.md)<!-- -->&lt;T, U&gt;&gt;
The paths to fixtures created with `createIFF` and added with `CreateIFFResult#addFixtures`<!-- -->.
The paths to fixtures created with [createIFF()](./inline-fixture-files.createiff.md) and added with `addFixtures`<!-- -->.
10 changes: 6 additions & 4 deletions docs/api/inline-fixture-files.createiffresult.fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

Change the root directory and take over the fixture you created.

Internally, first a new root directory is created, and then the fixtures from the old root directory are copied into it. Finally, the fixtures specified in `additionalDirectory` are added to the new root directory.

The copy operation will attempt to create a copy-on-write reflink. If the platform does not support copy-on-write, then a fallback copy mechanism is used.

**Signature:**

```typescript
Expand All @@ -27,6 +23,12 @@ fork<const U extends Directory>(additionalDirectory: U, options: CreateIFFOption
Promise&lt;[ForkResult](./inline-fixture-files.forkresult.md)<!-- -->&lt;T, U&gt;&gt;
## Remarks
Internally, first a new root directory is created, and then the fixtures from the old root directory are copied into it. Finally, the fixtures specified in `additionalDirectory` are added to the new root directory.
The copy operation will attempt to create a copy-on-write reflink. If the platform does not support copy-on-write, then a fallback copy mechanism is used.
## Example
Expand Down
2 changes: 1 addition & 1 deletion docs/api/inline-fixture-files.createiffresult.join.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## CreateIFFResult.join() method

Join `rootDir` and `paths`<!-- -->. That is, it is equivalent to `require('path').join(rootDir, ...paths)`<!-- -->.
Join `rootDir` and `paths`<!-- -->. It is equivalent to `require('path').join(rootDir, ...paths)`<!-- -->.

**Signature:**

Expand Down
12 changes: 6 additions & 6 deletions docs/api/inline-fixture-files.createiffresult.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export interface CreateIFFResult<T extends Directory>
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [paths](./inline-fixture-files.createiffresult.paths.md) | | FlattenDirectory&lt;T&gt; | The paths of the fixtures. It is useful to get the path of fixtures in type safety. |
| [rootDir](./inline-fixture-files.createiffresult.rootdir.md) | | string | The directory where fixtures are written. This directory is obtained by processing the directory specified in <code>CreateIFFOptions#rootDir</code> using <code>path.resolve</code>. |
| [rootDir](./inline-fixture-files.createiffresult.rootdir.md) | | string | The directory where fixtures are written. This directory is obtained by processing the directory specified in [CreateIFFOptions.rootDir](./inline-fixture-files.createiffoptions.rootdir.md) using <code>path.resolve</code>. |

## Methods

| Method | Description |
| --- | --- |
| [addFixtures(additionalDirectory)](./inline-fixture-files.createiffresult.addfixtures.md) | Add fixtures to <code>rootDir</code>. |
| [fork(additionalDirectory, options)](./inline-fixture-files.createiffresult.fork.md) | <p>Change the root directory and take over the fixture you created.</p><p>Internally, first a new root directory is created, and then the fixtures from the old root directory are copied into it. Finally, the fixtures specified in <code>additionalDirectory</code> are added to the new root directory.</p><p>The copy operation will attempt to create a copy-on-write reflink. If the platform does not support copy-on-write, then a fallback copy mechanism is used.</p> |
| [join(paths)](./inline-fixture-files.createiffresult.join.md) | Join <code>rootDir</code> and <code>paths</code>. That is, it is equivalent to <code>require('path').join(rootDir, ...paths)</code>. |
| [rmFixtures()](./inline-fixture-files.createiffresult.rmfixtures.md) | Delete fixtures under <code>rootDir</code>. |
| [rmRootDir()](./inline-fixture-files.createiffresult.rmrootdir.md) | Delete <code>rootDir</code>. |
| [addFixtures(additionalDirectory)](./inline-fixture-files.createiffresult.addfixtures.md) | Add fixtures to [rootDir](./inline-fixture-files.createiffoptions.rootdir.md)<!-- -->. |
| [fork(additionalDirectory, options)](./inline-fixture-files.createiffresult.fork.md) | Change the root directory and take over the fixture you created. |
| [join(paths)](./inline-fixture-files.createiffresult.join.md) | Join <code>rootDir</code> and <code>paths</code>. It is equivalent to <code>require('path').join(rootDir, ...paths)</code>. |
| [rmFixtures()](./inline-fixture-files.createiffresult.rmfixtures.md) | Delete fixtures under [rootDir](./inline-fixture-files.createiffoptions.rootdir.md)<!-- -->. |
| [rmRootDir()](./inline-fixture-files.createiffresult.rmrootdir.md) | Delete [rootDir](./inline-fixture-files.createiffoptions.rootdir.md)<!-- -->. |

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## CreateIFFResult.rmFixtures() method

Delete fixtures under `rootDir`<!-- -->.
Delete fixtures under [rootDir](./inline-fixture-files.createiffoptions.rootdir.md)<!-- -->.

**Signature:**

Expand Down
2 changes: 1 addition & 1 deletion docs/api/inline-fixture-files.createiffresult.rmrootdir.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## CreateIFFResult.rmRootDir() method

Delete `rootDir`<!-- -->.
Delete [rootDir](./inline-fixture-files.createiffoptions.rootdir.md)<!-- -->.

**Signature:**

Expand Down
2 changes: 1 addition & 1 deletion docs/api/inline-fixture-files.createiffresult.rootdir.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## CreateIFFResult.rootDir property

The directory where fixtures are written. This directory is obtained by processing the directory specified in `CreateIFFOptions#rootDir` using `path.resolve`<!-- -->.
The directory where fixtures are written. This directory is obtained by processing the directory specified in [CreateIFFOptions.rootDir](./inline-fixture-files.createiffoptions.rootdir.md) using `path.resolve`<!-- -->.

**Signature:**

Expand Down
2 changes: 1 addition & 1 deletion docs/api/inline-fixture-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

| Function | Description |
| --- | --- |
| [createIFF(directory, options)](./inline-fixture-files.createiff.md) | Create fixtures in the specified directory. The path separator must be in POSIX format (<code>/</code>). Use of Windows path separator is an undefined behavior. |
| [createIFF(directory, options)](./inline-fixture-files.createiff.md) | Create fixtures in the specified directory. |

## Interfaces

Expand Down
20 changes: 11 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface ForkResult<T extends Directory, U extends Directory> extends Cr
export interface CreateIFFResult<T extends Directory> {
/**
* The directory where fixtures are written.
* This directory is obtained by processing the directory specified in `CreateIFFOptions#rootDir`
* This directory is obtained by processing the directory specified in {@link CreateIFFOptions.rootDir}
* using `path.resolve`.
*/
rootDir: string;
Expand Down Expand Up @@ -86,8 +86,7 @@ export interface CreateIFFResult<T extends Directory> {
*/
paths: FlattenDirectory<T>;
/**
* Join `rootDir` and `paths`.
* That is, it is equivalent to `require('path').join(rootDir, ...paths)`.
* Join `rootDir` and `paths`. It is equivalent to `require('path').join(rootDir, ...paths)`.
*
* @example
* This is useful for generating paths to files not created by `createIFF`.
Expand All @@ -100,22 +99,23 @@ export interface CreateIFFResult<T extends Directory> {
*/
join(...paths: string[]): string;
/**
* Delete `rootDir`.
* Delete {@link CreateIFFOptions.rootDir | rootDir}.
*/
rmRootDir(): Promise<void>;
/**
* Delete fixtures under `rootDir`.
* Delete fixtures under {@link CreateIFFOptions.rootDir | rootDir}.
*/
rmFixtures(): Promise<void>;
/**
* Add fixtures to `rootDir`.
* Add fixtures to {@link CreateIFFOptions.rootDir | rootDir}.
* @param additionalDirectory - The definition of fixtures to be added.
* @returns The paths to fixtures created with `createIFF` and added with `CreateIFFResult#addFixtures`.
* @returns The paths to fixtures created with {@link createIFF} and added with `addFixtures`.
*/
addFixtures<const U extends Directory>(additionalDirectory: U): Promise<AddFixturesResult<T, U>>;
/**
* Change the root directory and take over the fixture you created.
*
* @remarks
* Internally, first a new root directory is created, and then the fixtures from the old root directory are copied into it.
* Finally, the fixtures specified in `additionalDirectory` are added to the new root directory.
*
Expand Down Expand Up @@ -152,8 +152,10 @@ export interface CreateIFFResult<T extends Directory> {

/**
* Create fixtures in the specified directory.
* The path separator must be in POSIX format (`/`).
* Use of Windows path separator is an undefined behavior.
*
* @remarks
* The path must be in POSIX-style (`'dir/file.txt'`).
* Use of Windows-style path (`'dir\\file.txt'`) is an undefined behavior.
*
* @example
* ```ts
Expand Down

0 comments on commit b3e4e79

Please sign in to comment.