Skip to content

Commit

Permalink
Improved documentation of references
Browse files Browse the repository at this point in the history
  • Loading branch information
karelvaculik committed Aug 31, 2023
1 parent 45d6ebc commit 21a9251
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 110 deletions.
18 changes: 11 additions & 7 deletions docs/references.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ a plot ([`plot_graph()`](../api/pyreball_html/#pyreball.html.plot_graph)), or
a heading ([`print_h1()`](../api/pyreball_html/#pyreball.html.print_h1), ...,
[`print_h6()`](../api/pyreball_html/#pyreball.html.print_h6)).
Each such function then creates a target for the link.
To create a source, just retrieve the string representation of the reference (i.e. use `__str__()` method), or invoke a
call on the reference object (i.e. use `__call__()` method).
To create a source, just retrieve the string representation of the reference (i.e.
use [`__str__()`](../api/pyreball_html/#pyreball.html.Reference.__str__) method), or invoke a
call on the reference object (i.e. use [`__call__()`](../api/pyreball_html/#pyreball.html.Reference.__call__) method).

The following snippet demonstrates a very simple usage of a reference object.

Expand All @@ -22,9 +23,11 @@ The following snippet demonstrates a very simple usage of a reference object.

The code above creates a reference object with default link text `My Table` and the reference object is assigned to the
table.
The code also creates three instances of the same link pointing to the table. `__str__()` method uses the default string
The code also creates three instances of the same link pointing to the
table. [`__str__()`](../api/pyreball_html/#pyreball.html.Reference.__str__) method uses the default string
that we passed to the constructor.
The last link was created by `__call__()` method, which takes a parameter that is used to override the default link
The last link was created by [`__call__()`](../api/pyreball_html/#pyreball.html.Reference.__call__) method, which takes
a parameter that is used to override the default link
text.

When default link text is not provided through the constructor, Pyreball uses table numbers as texts for links pointing
Expand All @@ -39,6 +42,7 @@ The artificial example below demonstrates some of these features.

!!! note

Creating references explicitly through the constructor of `Reference` class allows us to use
the reference object even before the target object is created. This would not be possible if the references
were created by functions like [`print_table()`](../api/pyreball_html/#pyreball.html.print_table).
Creating references explicitly through the constructor of [`Reference`](../api/pyreball_html/#pyreball.html.Reference)
class allows us to use the reference object even before the target object is created.
This would not be possible if the references were created by functions like
[`print_table()`](../api/pyreball_html/#pyreball.html.print_table).
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ plugins:
options:
members_order: alphabetical
separate_signature: true
filters: [ "!^_", "!print_html" ]
filters: [ "!^_", "!print_html", "__str__", "__call__" ]
docstring_options:
ignore_init_summary: true
merge_init_into_class: true
Expand Down
Loading

0 comments on commit 21a9251

Please sign in to comment.