doc: gh_utils: add docstring for get_page_prefix

Add documentation to the get_page_prefix method.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit is contained in:
Benjamin Cabé 2023-11-03 15:44:39 +01:00 committed by Carles Cufí
parent a39d2dc9d5
commit 0f07889bcd

View file

@ -51,6 +51,20 @@ __version__ = "0.1.0"
def get_page_prefix(app: Sphinx, pagename: str) -> str:
"""Return the prefix that needs to be added to the page path to get its location in the
repository.
If pagename refers to a page that is automatically generated by Sphinx or if it matches one of
the patterns in ``gh_link_exclude`` configuration option, return None.
Args:
app: Sphinx instance.
pagename: Page name (path).
Returns:
Prefix if applicable, None otherwise.
"""
if not os.path.isfile(app.env.project.doc2path(pagename)):
return None