forked from TypeStrong/typedoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.ts
99 lines (84 loc) · 2.42 KB
/
file.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import * as Path from "path";
import type { Reflection } from "../reflections/abstract";
import type { ReflectionGroup } from "../ReflectionGroup";
import type { SourceDirectory } from "./directory";
import type { RepositoryType } from "./repository";
/**
* Represents references of reflections to their defining source files.
*
* @see {@link DeclarationReflection.sources}
*/
export interface SourceReference {
/**
* A reference to the corresponding file instance.
*/
file?: SourceFile;
/**
* The filename of the source file.
*/
fileName: string;
/**
* The number of the line that emitted the declaration.
*/
line: number;
character: number;
/**
* URL for displaying the source file.
*/
url?: string;
}
/**
* Exposes information about a source file.
*
* One may access a list of all source files through the {@link ProjectReflection.files} property or as
* a tree structure through the {@link ProjectReflection.directory} property.
*
* Furthermore each reflection carries references to the related SourceFile with their
* {@link DeclarationReflection.sources} property. It is an array of of {@link SourceReference} instances
* containing the reference in their {@link SourceReference.file} field.
*/
export class SourceFile {
/**
* The original full system file name.
*/
fullFileName: string;
/**
* A trimmed version of the file name. Contains only the path relative to the
* determined base path.
*/
fileName: string;
/**
* The base name of the file.
*/
name: string;
/**
* A URL pointing to a page displaying the contents of this file.
*/
url?: string;
/**
* The type of repository where this file is hosted.
*/
repositoryType?: RepositoryType;
/**
* The representation of the parent directory of this source file.
*/
parent?: SourceDirectory;
/**
* A list of all reflections that are declared in this file.
*/
reflections: Reflection[] = [];
/**
* A grouped list of the reflections declared in this file.
*/
groups?: ReflectionGroup[];
/**
* Create a new SourceFile instance.
*
* @param fullFileName The full file name.
*/
constructor(fullFileName: string) {
this.fileName = fullFileName;
this.fullFileName = fullFileName;
this.name = Path.basename(fullFileName);
}
}