Skip to content

Commit

Permalink
Docs: adding a link to the source file on GitHub (motis-project#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas-C authored Jan 17, 2025
1 parent ea6bcff commit 69e700e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,23 @@
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
html_logo = './motis-logo.svg'
html_theme_options = {
'style_external_links': True,
}

from pathlib import Path
from docutils import nodes
from breathe.renderer.sphinxrenderer import SphinxRenderer

URL_TEMPLATE = "https://github.com/motis-project/utl/blob/master/{file_path}#L{line}"
REPO_ROOT_DIR = Path(__file__).parent.parent

def create_doxygen_target(self, node):
loc = node.location
file_path = loc.file[len(str(REPO_ROOT_DIR))+1:]
url = URL_TEMPLATE.format(file_path=file_path, line=loc.line)
title = f"{file_path} on line {loc.line}"
return [nodes.reference("", "", refuri=url, reftitle=title)]

# Monkey patching this method:
SphinxRenderer.create_doxygen_target = create_doxygen_target
8 changes: 8 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,23 @@ utl::info("MyCtx", "Message").attrs({{"key1", "value1"}, {"key2", "value2"}});
### API details
:::{doxygenstruct} utl::log
:no-link:
:members:
:::
:::{doxygenstruct} utl::debug
:no-link:
:members:
:::
:::{doxygenstruct} utl::info
:no-link:
:members:
:::
:::{doxygenstruct} utl::error
:no-link:
:members:
:::
:::{note}
Expand Down
1 change: 1 addition & 0 deletions include/utl/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ struct log {
}
}

/// Add key-values metadata
void attrs(
std::initializer_list<std::pair<std::string_view, std::string_view> >&&
attrs) {
Expand Down

0 comments on commit 69e700e

Please sign in to comment.