Skip to content

Commit 69e700e

Browse files
authored
Docs: adding a link to the source file on GitHub (motis-project#30)
1 parent ea6bcff commit 69e700e

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

docs/conf.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,23 @@
4545
html_theme = 'sphinx_rtd_theme'
4646
html_static_path = ['_static']
4747
html_logo = './motis-logo.svg'
48+
html_theme_options = {
49+
'style_external_links': True,
50+
}
51+
52+
from pathlib import Path
53+
from docutils import nodes
54+
from breathe.renderer.sphinxrenderer import SphinxRenderer
55+
56+
URL_TEMPLATE = "https://github.com/motis-project/utl/blob/master/{file_path}#L{line}"
57+
REPO_ROOT_DIR = Path(__file__).parent.parent
58+
59+
def create_doxygen_target(self, node):
60+
loc = node.location
61+
file_path = loc.file[len(str(REPO_ROOT_DIR))+1:]
62+
url = URL_TEMPLATE.format(file_path=file_path, line=loc.line)
63+
title = f"{file_path} on line {loc.line}"
64+
return [nodes.reference("", "", refuri=url, reftitle=title)]
65+
66+
# Monkey patching this method:
67+
SphinxRenderer.create_doxygen_target = create_doxygen_target

docs/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,23 @@ utl::info("MyCtx", "Message").attrs({{"key1", "value1"}, {"key2", "value2"}});
4646
4747
### API details
4848
:::{doxygenstruct} utl::log
49+
:no-link:
50+
:members:
4951
:::
5052
5153
:::{doxygenstruct} utl::debug
54+
:no-link:
55+
:members:
5256
:::
5357
5458
:::{doxygenstruct} utl::info
59+
:no-link:
60+
:members:
5561
:::
5662
5763
:::{doxygenstruct} utl::error
64+
:no-link:
65+
:members:
5866
:::
5967
6068
:::{note}

include/utl/logging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct log {
7878
}
7979
}
8080

81+
/// Add key-values metadata
8182
void attrs(
8283
std::initializer_list<std::pair<std::string_view, std::string_view> >&&
8384
attrs) {

0 commit comments

Comments
 (0)