Skip to content

Commit 1287adc

Browse files
committed
--auto-abstract is now default
1 parent 029a91c commit 1287adc

12 files changed

Lines changed: 97 additions & 114 deletions

src/Abstract.asciidoc

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
:doctitle: Abstract Description
2+
:sectnums:
3+
:toc: left
4+
:toclevels: 4
5+
6+
## Introduction
7+
8+
The documentation looks best if each documented identifier has an _"abstract"_, which means just _"a short description"_. This should usually be just one sentence.
9+
10+
Such abstract description is displayed in various overview pages. It's also used in conjunction with the link:SeeAlsoTag[@seealso tag].
11+
12+
It can be provided:
13+
14+
- using the `@abstract` tag
15+
16+
- or (recommended) it will be automatically deduced from the first sentence of the description. This automatic deduction can be turned off using the `--no-auto-abstract` command-line option.
17+
18+
## `@abstract` tag
19+
20+
You can use the `@abstract` tag to explicitly delimit a short explanation of the documented item. There should be at most one `@abstract` tag per description.
21+
22+
Example:
23+
24+
[source,pascal]
25+
----
26+
{ @abstract(Read JSON file.)
27+
Read the JSON file indicated by the given URL.
28+
The resulting JSON object is owned by the caller, and must be freed by the caller. }
29+
function ReadJson(const Url: string): TJsonValue;
30+
----
31+
32+
The abstract description provided this way is always separated from the rest of the description by a paragraph break. This is in contrast to the case when the abstract description is deduced automatically from the first sentence of the description (see below), where paragraph break is done only if you explicitly insert an empty line between the first sentence and the rest of the description.
33+
34+
## Automatic determination of abstract description
35+
36+
If no `@abstract` tag is present in the description of an item, we will deduce the abstract description from the first sentence of the full description. Example:
37+
38+
[source,pascal]
39+
----
40+
{ Read JSON file.
41+
Read the JSON file indicated by the given URL.
42+
The resulting JSON object is owned by the caller, and must be freed by the caller. }
43+
function ReadJson(const Url: string): TJsonValue;
44+
----
45+
46+
The first sentence is determined by looking for a _first period followed by any whitespace_ (including newline). If there is no such period in the description, then the _whole_ description is treated as one sentence, and the _whole_ description is treated as an abstract description of the item.
47+
48+
We recommend to utilize this automatic deduction of the abstract description. It makes the comments look less cluttered when you don't need to write `@abstract` everywhere.
49+
50+
Write the documentation such that **the first sentence of every description "stands on its own"**.
51+
52+
## Disable automatic deduction of abstract description (`--no-auto-abstract`)
53+
54+
If you really want to, you can disable the automatic deduction of the abstract description by using the `--no-auto-abstract` command-line option. In this case, if no `@abstract` tag is present in the description of an item, then no abstract description will be generated for that item.
55+
56+
## Other software
57+
58+
- This is a standard feature of _JavaDoc_ as well.
59+
60+
- https://www.doxygen.nl/manual/docblocks.html[Doxygen also has a similar feature]. With `JAVADOC_AUTOBRIEF` enabled, the first sentence of the description is used as a brief description, just like with _JavaDoc_ and _PasDoc_. Without `JAVADOC_AUTOBRIEF`, you still don't have to write `\brief` to provide a brief description, as long as you separate first line of the description from the rest of the description with a newline.
61+
62+
## Example unit
63+
64+
See https://github.com/pasdoc/pasdoc/blob/master/tests/testcases/ok_auto_abstract.pas[test unit of this feature].
65+

src/AbstractTag.asciidoc

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
11
:doctitle: @abstract tag
22

3-
For some item types like classes or units you may write very large
4-
descriptions to give an adequate introduction. However, these large
5-
texts are not appropriate in an overview list. Use the abstract tag to
6-
give a short explanation of what an item is about. One row of text is a
7-
good rule of thumb. Of course, there should only be one abstract tag per
8-
description.
9-
10-
Example:
11-
12-
[source,pascal]
13-
----
14-
type
15-
{ @abstract(This class does some very useful thing.)
16-
With the help of this class you can ...
17-
(more text that describes how very very
18-
useful is this class follows). }
19-
TMyClass = class ...
20-
----
21-
22-
The abstract text will appear in the overview section of the
23-
documentation (if the document format supports this overview section),
24-
and will also appear as the first paragraph of the item full
25-
documentation.
26-
27-
Note that can avoid writing explicit @abstract tag if you use
28-
link:AutoAbstractOption[--auto-abstract command-line option].
3+
The `@abstract` docs moved to the link:Abstract[Abstract Description] page of the documentation.

src/AdvancedFeatures.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Some important non-obvious PasDoc features:
77

88
== Input
99

10-
* link:AutoAbstractOption[--auto-abstract] command-line option allows you to automatically treat the 1st sentence of the description as an abstract.
10+
* We automatically treat the 1st sentence of the description as an link:Abstract[abstract]. So make sure it "stands on its own" and is a good short description of the item. You can also explicitly specify the abstract using link:Abstract[@abstract tag].
1111

1212
* You can write entire pages using pasdoc syntax, with all supported link:SupportedTags[@tags]. This way you can use pasdoc like a simple document creation tool. See the link:IntroductionAndConclusion[Introduction and conclusion] documentation.
1313

src/AutoAbstractOption.asciidoc

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,3 @@
11
:doctitle: --auto-abstract command-line option
22

3-
## [[overview]] Overview
4-
5-
If you run pasdoc with --auto-abstract link:CommandLine[CommandLine]
6-
option, pasdoc will automatically deduce the abstract description of
7-
every item from the first sentence of it's description. This means that
8-
you can write
9-
10-
[source,pascal]
11-
----
12-
type
13-
{ Short description of this class.
14-
More elaborate description of this class. }
15-
TMyClass = class
16-
----
17-
18-
and it's equivalent to
19-
20-
[source,pascal]
21-
----
22-
type
23-
{ @abstract(Short description of this class.)
24-
More elaborate description of this class. }
25-
TMyClass = class
26-
----
27-
28-
This means that you can avoid writing explicitly @abstract tags, which
29-
means that your comments look less cluttered. Of course, this also means
30-
that you have to carefully watch to make the first sentence of every
31-
description to "stand on it's own".
32-
33-
This is a standard feature of javadoc, and it's also available in
34-
doxygen.
35-
36-
The parsing logic is simple: the first sentence of the description ends
37-
at the first period followed by any whitespace (including newline). Of
38-
course this period must be in the "top-level" text, not inside parameter
39-
of any @-tag. If there is no such period in the description, then the
40-
_whole_ description is treated as one sentence, and the _whole_
41-
description is treated as an abstract description of the item.
42-
43-
Of course if any description has an explicit @abstract section, then
44-
this has priority over "the first sentence rule". Using explicit
45-
@abstract tag may be useful if e.g. you need to make the abstract
46-
description two-sentence long.
47-
48-
## [[small-difference-between-explicit-abstract]] Small difference between explicit @abstract
49-
50-
Note that there is actually a small difference between two examples
51-
given above. It occurs when pasdoc writes full description of a given
52-
item (full = abstract one + the rest).
53-
54-
If you used explicit @abstract tag, then pasdoc will always separate the
55-
abstract description with some space (e.g. paragraph marker, <p>, in
56-
HTML) from the rest of the description. But if your abstract description
57-
was deduced automatically, then pasdoc will not automatically insert
58-
such paragraph. This way full description of an item looks more like it
59-
was specified in source code.
60-
61-
So if I would really want to make two exactly equivalent examples, I
62-
should show this as the first example (note that I explicitly inserted
63-
empty line between abstract description and the rest here):
64-
65-
[source,pascal]
66-
----
67-
type
68-
{ Short description of this class.
69-
70-
More elaborate description of this class. }
71-
TMyClass = class
72-
...
73-
----
74-
75-
## [[example-unit]] Example unit
76-
77-
See https://github.com/pasdoc/pasdoc/blob/master/tests/testcases/ok_auto_abstract.pas[test unit of this feature].
3+
The `--auto-abstract` docs moved to the link:Abstract[Abstract Description] page of the documentation.

src/CommandLine.asciidoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ How multipart links (like @link(Unit.Procedure)) look like in output
123123
link:LinkLookOption[--full-link]::
124124
Obsolete name for --link-look=full option.
125125

126-
link:AutoAbstractOption[--auto-abstract]::
127-
Automatically deduce @abstract description of item from 1st sentence of it's full description
126+
link:Abstract[--auto-abstract]::
127+
Deprecated. This is the default now.
128128

129129
link:CssOption[--css, --css-based-on-bootstrap]::
130130
Use the code of your cascading style sheet in replacement of default one.
@@ -150,6 +150,9 @@ Specify the name of a text file that should be inserted into the preamble of a L
150150
link:ImplicitVisibilityOption[--implicit-visibility]::
151151
How pasdoc should handle class members within default class visibility.
152152

153+
link:Abstract[--no-auto-abstract]::
154+
Disable automatic deduction of abstract description from the first sentence of the full description.
155+
153156
link:NoMacroOption[--no-macro]::
154157
Turn FPC macro support off.
155158

src/SeeAlsoTag.asciidoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ multiple items that are related to this item.
1313

1414
In output documentation, this will result in "See also" section created
1515
in description of this item. This section will list all items specified
16-
by @seealso tags. Abstract descriptions (the one created e.g. by
17-
link:AbstractTag[@abstract tag]) of each related item will also be
16+
by @seealso tags. link:Abstract[Abstract description] of each related item will also be
1817
shown.
1918

2019
## [[simple-example]] Simple example

src/SupportedTags.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ others do not, see link:TagsParameters[TagsParameters].
1010
Alphabetical list of supported tags:
1111

1212
@@:: Insert the @ character literally
13-
link:AbstractTag[@abstract]:: Specify a short abstract of the description
13+
link:Abstract[@abstract]:: Specify a short abstract of the description
1414
link:IntroductionAndConclusion[@anchor]:: Set up an invisible anchor inside introduction/conclusion
1515
link:AuthorTag[@author]:: Specify an author's name (and email address etc.)
1616
link:BoldAndItalicTags[@bold]:: Format text using bold font

src/WhereToPlaceComments.asciidoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
:doctitle: Where To Place Comments
2+
:sectnums:
3+
:toc: left
4+
:toclevels: 4
25

36
## [[basic-rule]] Basic rule
47

src/WritingDocumentation.asciidoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
:doctitle: Writing Documentation Comments
2+
:sectnums:
3+
:toc: left
4+
:toclevels: 4
5+
6+
## Introduction
27

38
PasDoc extracts documentation from the comments that you place in your
49
source code (and from external files if you use the
@@ -8,6 +13,10 @@ See link:WhereToPlaceComments[WhereToPlaceComments] for more explanation
813
*where* to place comments. This page describes special syntax *features
914
available in documentation comments*.
1015

16+
## First sentence should stand on its own
17+
18+
The first sentence of every documentation comment is the most important. It determines the link:Abstract[abstract (short) description] of this item, which is shown in various overviews, and as such should "stand on its own". Make it a short and precise sentence that describes the item.
19+
1120
## [[expanding-tags]] Expanding @-tags
1221

1322
See link:SupportedTags[SupportedTags].

src/_Sidebar.asciidoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Features: ::
1515

1616

1717
link:SupportedTags[Supported Tags]: ::
18-
* link:AbstractTag[@abstract]
18+
* link:Abstract[@abstract]
1919
* link:AuthorTag[@author]
2020
* link:BoldAndItalicTags[@bold, @italic]
2121
* link:BrTag[@br]
@@ -55,7 +55,7 @@ link:CommandLine[Command Line]: ::
5555
** link:LatexOutput[--format=latex]
5656
** link:Latex2RtfOutput[--format=latex2rtf]
5757
** link:SimpleXmlOutput[--format=simplexml]
58-
* link:AutoAbstractOption[--auto-abstract]
58+
* link:Abstract[--auto-abstract]
5959
* link:AutoBackComments[--auto-back-comments]
6060
* link:AutoLinkOption[--auto-link, --auto-link-exclude]
6161
* link:CacheOption[--cache]
@@ -80,6 +80,7 @@ link:CommandLine[Command Line]: ::
8080
* link:LinkLookOption[--link-look]
8181
* link:MarkdownOption[--markdown]
8282
* link:NameOption[--name]
83+
* link:Abstract[--no-auto-abstract]
8384
* link:NoMacroOption[--no-macro]
8485
* link:OutputLanguage[--language]
8586
* link:OutputOption[--output]

0 commit comments

Comments
 (0)