1
- # Documentables Model
1
+ # Documentable Model
2
2
3
- Documentables represent data that is parsed from sources. Think of this data model as of something that could be
4
- seen or produced by a compiler frontend, it's not far off from the truth.
3
+ The Documentable model represents the data that is parsed from some programming language sources. Think of this data as
4
+ of something that could be seen or produced by a compiler frontend, it's not far off from the truth.
5
5
6
- By default, documentables are parsed from ` Descriptor ` (for ` Kotlin ` )
7
- and [ Psi] ( https://plugins.jetbrains.com/docs/intellij/psi.html )
8
- (for ` Java ` ) models. Code-wise, you can have a look at following classes:
6
+ By default, the documentables are created from:
9
7
10
- * ` DefaultDescriptorToDocumentableTranslator ` - responsible for ` Kotlin ` -> ` Documentable ` mapping
11
- * ` DefaultPsiToDocumentableTranslator ` - responsible for ` Java ` -> ` Documentable ` mapping
8
+ * Descriptors (Kotlin's K1 compiler)
9
+ * Symbols (Kotlin's K2 compiler)
10
+ * [ PSI] ( https://plugins.jetbrains.com/docs/intellij/psi.html ) (Java's model).
12
11
13
- Upon creation, it's a collection of trees, each with ` DModule ` as root.
12
+ Code-wise, you can have a look at following classes:
14
13
15
- Take some arbitrary ` Kotlin ` source code that is located within the same module:
14
+ * ` DefaultDescriptorToDocumentableTranslator ` - responsible for Kotlin -> ` Documentable ` mapping
15
+ * ` DefaultPsiToDocumentableTranslator ` - responsible for Java -> ` Documentable ` mapping
16
+
17
+ Upon creation, the documentable model represents a collection of trees, each with ` DModule ` as root.
18
+
19
+ Take some arbitrary Kotlin source code that is located within the same module:
16
20
17
21
``` kotlin
18
22
// Package 1
@@ -28,7 +32,7 @@ enum class Enum { }
28
32
val topLevelProperty: String
29
33
```
30
34
31
- This would be represented roughly as the following ` Documentable ` tree:
35
+ This would be represented roughly as the following Documentable tree:
32
36
33
37
``` mermaid
34
38
flowchart TD
@@ -43,20 +47,23 @@ flowchart TD
43
47
secondPackage --> secondPackageProperty[DProperty]
44
48
```
45
49
46
- At later stages of transformation, all trees are folded into one (by ` DocumentableMerger ` ).
50
+ At later stages of transformation, all trees are folded into one by
51
+ [ DocumentableMerger] ( ../extension_points/core_extension_points.md#documentablemerger ) .
47
52
48
53
## Documentable
49
54
50
- The main building block of documentables model is ` Documentable ` class. It's the base class for all more specific types
51
- that represent elements of parsed sources with mostly self-explanatory names (` DFunction ` , ` DPackage ` , ` DProperty ` , etc)
52
- .
53
- ` DClasslike ` is the base class for class-like documentables such as ` DClass ` , ` DEnum ` , ` DAnnotation ` , etc.
55
+ The main building block of the documentable model is the ` Documentable ` class. It is the base class for all more specific
56
+ types. All implementations represent elements of source code with mostly self-explanatory names: ` DFunction ` ,
57
+ ` DPackage ` , ` DProperty ` , and so on.
58
+
59
+ ` DClasslike ` is the base class for all class-like documentables, such as ` DClass ` , ` DEnum ` , ` DAnnotation ` and others.
60
+
61
+ The contents of each documentable normally represent what you would see in the source code.
54
62
55
- The contents of each documentable normally represent what you would see in source code. For instance, if you open
56
- ` DClass ` , you should find that it contains references to functions, properties, companion object, constructors and so
57
- on.
58
- ` DEnum ` should have references to enum entries, and ` DPackage ` can have references to both classlikes and top-level
59
- functions and properties (` Kotlin ` -specific).
63
+ For example, if you open
64
+ ` DClass ` , you should find that it contains references to functions, properties, companion objects, constructors and so
65
+ on. ` DEnum ` should have references to its entries, and ` DPackage ` can have references to both classlikes and top-level
66
+ functions and properties (Kotlin-specific).
60
67
61
68
Here's an example of a documentable:
62
69
@@ -85,7 +92,7 @@ data class DClass(
85
92
86
93
___
87
94
88
- There are three non-documentable classes that important for this model:
95
+ There are three non-documentable classes that are important for this model:
89
96
90
97
* ` DRI `
91
98
* ` SourceSetDependent `
@@ -94,9 +101,9 @@ There are three non-documentable classes that important for this model:
94
101
### DRI
95
102
96
103
` DRI ` stans for _ Dokka Resource Identifier_ - a unique value that identifies a specific ` Documentable ` .
97
- All references and relations between documentables (other than direct ownership) are described using ` DRI ` .
104
+ All references and relations between the documentables (other than direct ownership) are described using ` DRI ` .
98
105
99
- For example, ` DFunction ` with a parameter of type ` Foo ` has only ` Foo ` 's ` DRI ` , not the actual reference
106
+ For example, ` DFunction ` with a parameter of type ` Foo ` only has ` Foo ` 's ` DRI ` , but not the actual reference
100
107
to ` Foo ` 's ` Documentable ` object.
101
108
102
109
#### Example
@@ -146,11 +153,11 @@ kotlinx.coroutines/MainCoroutineDispatcher/limitedParallelism/#kotlin.Int/Pointi
146
153
### SourceSetDependent
147
154
148
155
` SourceSetDependent ` helps handling multiplatform data by associating platform-specific data (declared with either
149
- ` expect ` or ` actual ` modifier ) with particular
156
+ ` expect ` or ` actual ` modifiers ) with particular
150
157
[ source sets] ( https://kotlinlang.org/docs/multiplatform-discover-project.html#source-sets ) .
151
158
152
- This comes in handy if ` expect ` / ` actual ` declarations differ. For instance , the default value for ` actual ` might differ
153
- from that declared in ` expect ` , or code comments written for ` expect ` might be different from what's written
159
+ This comes in handy if the ` expect ` / ` actual ` declarations differ. For example , the default value for ` actual ` might
160
+ differ from that declared in ` expect ` , or code comments written for ` expect ` might be different from what's written
154
161
for ` actual ` .
155
162
156
163
Under the hood, it's a ` typealias ` to a ` Map ` :
@@ -171,18 +178,18 @@ ___
171
178
172
179
## Documentation model
173
180
174
- Documentation model is used alongside Documentables to store data obtained by parsing
175
- code comments (such as ` KDoc ` / ` Javadoc ` ).
181
+ The Documentation model is used alongside documentables to store data obtained by parsing
182
+ code comments (such as KDocs / Javadocs ).
176
183
177
184
### DocTag
178
185
179
186
` DocTag ` describes a specific documentation syntax element.
180
187
181
- It's universal across source languages . For instance, DocTag ` B ` is the same for ` **bold** ` in ` Kotlin ` and
182
- ` <b>bold</b> ` in ` Java ` .
188
+ It's universal across language sources . For example, the DocTag ` B ` is the same for ` **bold** ` in Kotlin and
189
+ ` <b>bold</b> ` in Java.
183
190
184
- However, some ` DocTag ` elements are specific to a certain language, there are many such examples for ` Java `
185
- because it allows HTML tags inside ` Javadoc ` comments, some of which are simply not possible to reproduce with ` Markdown ` .
191
+ However, some DocTag elements are specific to one language. There are many such examples for Java, because it allows
192
+ HTML tags inside the Javadoc comments, some of which are simply not possible to reproduce with Markdown that KDocs use .
186
193
187
194
` DocTag ` elements can be deeply nested with other ` DocTag ` children elements.
188
195
@@ -218,10 +225,9 @@ data class CodeBlock(
218
225
219
226
### TagWrapper
220
227
221
- ` TagWrapper ` describes the whole comment description or a specific comment tag.
222
- For example: ` @see ` / ` @author ` / ` @return ` .
228
+ ` TagWrapper ` describes the whole comment description or a specific comment tag. For example: ` @see ` / ` @author ` / ` @return ` .
223
229
224
- Since each such section may contain formatted text inside of it, each ` TagWrapper ` has ` DocTag ` children.
230
+ Since each such section may contain formatted text inside it, each ` TagWrapper ` has ` DocTag ` children.
225
231
226
232
``` kotlin
227
233
/* *
0 commit comments