You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inside a description of one item you can place a link to another item
4
-
using @link link:SupportedTags[tag]. Depending on the type of output,
5
-
these links could be hyperlinks (in HTML) or page references (in LaTeX).
6
+
## Introduction
7
+
8
+
In a description of one item you can link to another item using the `@link` link:SupportedTags[tag]. The links are converted to be clickable references suitable for the output format.
6
9
7
10
Example:
8
11
@@ -11,45 +14,76 @@ Example:
11
14
const
12
15
MaxFactorialArgument = 20;
13
16
14
-
{ This function calculates factorial of n, n!.
15
-
You should always call this function with
17
+
{ Calculate factorial of n, @code(n!).
18
+
Always call this function with
16
19
n <= @link(MaxFactorialArgument),
17
20
otherwise result will not fit in Int64 type. }
18
21
function SmallFactorial(n: Integer): Int64;
19
22
----
20
23
21
-
You can link to _any_ item in your units that has some Pascal
22
-
identifier. So you can link not only to some procedure, constant,
23
-
variable, etc. but also to a whole class or a whole unit.
24
+
You can link to any item in your codebase, including:
25
+
26
+
- routines (procedures, functions),
27
+
- constants,
28
+
- types,
29
+
- enumeration types and enumerations members,
30
+
- variables,
31
+
- properties,
32
+
- fields,
33
+
- methods,
34
+
- units,
35
+
- classes, interfaces, records,
36
+
- and so on -- really every Pascal item that PasDoc found in the source code.
37
+
38
+
## Qualifying the linked item with class name, unit name, etc.
39
+
40
+
When resolving links, PasDoc follows similar namespace rules as the compiler. For example, within a class, you can link to its methods and properties directly (without specifying the class name). From the outside, you need to specify the class name, like `@link(TMyClass.MyMethod)`. You can qualify the link even more, with a unit name.
41
+
42
+
For example:
43
+
44
+
```pascal
45
+
unit MyUnit;
46
+
interface
24
47
25
-
You can use qualified names for the link target, like
48
+
type
49
+
{ Create an instance of this, then use @link(MyMethod) to do something. }
50
+
TMyClass = class
51
+
{ Sets @link(MyProperty) to 'foo'. }
52
+
procedure MyMethod;
53
+
{ Change this directly or by calling @link(MyMethod). }
* @link(SomeUnitName.IdentifierInThisUnit) or even
29
-
* @link(SomeUnitName.SomeClassName.Identifier).
61
+
{ Creates @link(SomeOtherUnit.TSomeOtherClass)
62
+
and calls @link(SomeUnit.TSomeOtherClass.SomeOtherMethod). }
63
+
procedure AnotherProcedure;
30
64
31
-
When resolving links, pasdoc tries to loosely mimic Pascal identifier
32
-
scope: The name of an identifier is first searched within the current
33
-
class / record etc., then within the current unit, then within the units
34
-
in the uses clause. Only if that fails pasdoc will search globally in
35
-
all known units.
65
+
implementation
66
+
end.
67
+
```
36
68
37
-
##[[explicit-display-name-of-a-link]] Explicit display name of a link
69
+
## Explicit caption of a link
38
70
39
-
You can also specify an explicit display name for this link, simply by
40
-
putting a space after your link target and then typing the link display
41
-
name. E.g.
71
+
By default, the link looks just like the name of the item it links to. And the multipart links look
72
+
can be customized using the `--link-look` link:CommandLine[CommandLine] option.
73
+
74
+
You can also specify an explicit caption for this link, simply by
75
+
putting a space after your link target and then typing the caption. E.g.
42
76
43
77
[source]
44
78
----
45
-
@link(TMyClass.MyMethod This is a silly link to MyMethod in TMyClass)
79
+
@link(TMyClass.MyMethod This is a link to MyMethod in TMyClass)
46
80
----
47
81
48
-
One use for such an explicit name is if you have a class TMemo that has
49
-
a property named Lines that returns an instance of a class TStringList.
50
-
You want to document routine TMemo.Clear, that calls Lines.Clear and
82
+
An example use for such an explicit caption is if you have a class `TMemo` that has
83
+
a property named Lines that returns an instance of a class `TStringList`.
84
+
You want to document routine `TMemo.Clear`, that calls `Lines.Clear` and
51
85
then does some repainting stuff. So you want to link in your description
52
-
to TStringList.Clear, but you want the link to show as Lines.Clear. You
86
+
to `TStringList.Clear`, but you want the link to show as `Lines.Clear`. You
53
87
can do it by writing a description like
54
88
55
89
[source,pascal]
@@ -64,5 +98,28 @@ type
64
98
end;
65
99
----
66
100
67
-
If no explicit display name was specified, then what multipart links
68
-
will look like depends on the `--link-look` link:CommandLine[CommandLine] option.
101
+
## Disambiguate links to overloaded routines
102
+
103
+
If you have overloaded routines, you can disambiguate the link by specifying the parameter types. For example, if you have two overloaded procedures `Foo`, one with no parameters and another with an `Integer` parameter, you can link to the first one using `@link(Foo())` and to the second one using `@link(Foo(Integer))`. Like this:
104
+
105
+
[source,pascal]
106
+
----
107
+
procedure Foo; overload;
108
+
procedure Foo(x: Integer); overload;
109
+
110
+
{ This calls @link(Foo()) and then @link(Foo(Integer)). }
111
+
procedure Bar;
112
+
----
113
+
114
+
You can still specify a caption after a space:
115
+
116
+
[source,pascal]
117
+
----
118
+
procedure Foo; overload;
119
+
procedure Foo(x: Integer); overload;
120
+
121
+
{ This calls @link(Foo() Foo without parameters)
122
+
and then @link(Foo(Integer) Foo with an Integer parameter). }
0 commit comments