Skip to content

Commit 0ccee52

Browse files
committed
New extended @link docs
1 parent ce4a60a commit 0ccee52

1 file changed

Lines changed: 85 additions & 28 deletions

File tree

src/LinkTag.asciidoc

Lines changed: 85 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
:doctitle: @link tag
2+
:sectnums:
3+
:toc: left
4+
:toclevels: 4
25

3-
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.
69

710
Example:
811

@@ -11,45 +14,76 @@ Example:
1114
const
1215
MaxFactorialArgument = 20;
1316
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
1619
n <= @link(MaxFactorialArgument),
1720
otherwise result will not fit in Int64 type. }
1821
function SmallFactorial(n: Integer): Int64;
1922
----
2023

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
2447

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). }
54+
property MyProperty: String read FMyProperty write FMyProperty;
55+
end;
56+
57+
{ Creates an instance of @link(TMyClass)
58+
and calls @link(TMyClass.MyMethod). }
59+
procedure SomeProcedure;
2660

27-
* @link(SomeClassName.IdentifierinThisClass) or
28-
* @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;
3064

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+
```
3668

37-
## [[explicit-display-name-of-a-link]] Explicit display name of a link
69+
## Explicit caption of a link
3870

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.
4276

4377
[source]
4478
----
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)
4680
----
4781

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
5185
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
5387
can do it by writing a description like
5488

5589
[source,pascal]
@@ -64,5 +98,28 @@ type
6498
end;
6599
----
66100

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). }
123+
procedure Bar;
124+
----
125+

0 commit comments

Comments
 (0)