Skip to content

Commit 4acaf1c

Browse files
committed
Document --show-source-position and friends
1 parent 148351c commit 4acaf1c

4 files changed

Lines changed: 43 additions & 0 deletions

File tree

src/CommandLine.asciidoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ Use the code of your cascading style sheet in replacement of default one.
129129
link:UseTipueSearchOption[--use-tipue-search]::
130130
Use tipue search engine in HTML output.
131131

132+
link:SourcePosition[--show-source-position, --source-url-pattern, --source-root]::
133+
Show (linked) source file names and line numbers.
134+
132135
link:SortOption[--sort]::
133136
Specifies what groups of items are sorted.
134137

src/SourcePosition.asciidoc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
:doctitle: Show (linked) source file names and line numbers
2+
3+
## --show-source-position
4+
5+
Use command-line option `--show-source-position` to show in the generated documentation the filename and line number where each identifier is declared. This is great to let developers reading the docs actually connect them with source files.
6+
7+
## --source-url-pattern
8+
9+
You can take it a step further by also using `--source-url-pattern=URL-PATTERN`. This will turn the source file / line numbers into a clickable link, leading to the given `URL-PATTERN`. The argument `URL-PATTERN` may have placeholders
10+
11+
- `{FILE}` (replaced by the filename, relative to `--source-root` if given, see below),
12+
13+
- `{LINE}` line number, 1-based.
14+
15+
For example
16+
17+
```
18+
--source-url-pattern='https://github.com/owner/repo/blob/main/{FILE}#L{LINE}'
19+
```
20+
21+
## --source-root
22+
23+
To make the behavior of `--show-source-position` and `--source-url-pattern` correct, we need to know the root of your project, relative to which we should show filenames (and put them in `{FILE}` replacement). You can provide it using `--source-root`.
24+
25+
What is the "correct source root" should be synchronized with the `--source-url-pattern` you use.
26+
If the `--source-url-pattern` points to the top-level of a GIT repository browser, then your `--source-root` should point to the root of your GIT repository.
27+
28+
When `--source-root-path` was not used, PasDoc doesn't know the "root" of your project, and all filenames (displayed and replaced) just show the filename without any directory.
29+
30+
## Example usage
31+
32+
```
33+
pasdoc /home/michalis/my_amazing_project/code/*.pas \
34+
--show-source-position \
35+
'--source-url-pattern=https://github.com/michaliskambi/my_amazing_project/blob/main/{FILE}#L{LINE}' \
36+
--source-root=/home/michalis/my_amazing_project
37+
```

src/_Sidebar.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ link:CommandLine[Command Line]: ::
8383
* link:OutputLanguage[--language]
8484
* link:OutputOption[--output]
8585
* link:ReadDescriptionFromFile[--description]
86+
* link:SourcePosition[--show-source-position, --source-url-pattern, --source-root]
8687
* link:SortOption[--sort]
8788
* link:SpellChecking[--spell-check, --spell-check-ignore-words]
8889
* link:UseTipueSearchOption[--use-tipue-search]

src/_includes/sidebar.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@
151151

152152
* [\--description](ReadDescriptionFromFile)
153153

154+
* [\--show-source-position, \--source-url-pattern, \--source-root](SourcePosition)
155+
154156
* [\--sort](SortOption)
155157

156158
* [\--spell-check, \--spell-check-ignore-words](SpellChecking)

0 commit comments

Comments
 (0)