mrdocs::files::makeProjectRelative

Make a source path relative to the mrdocs project root.

Synopsis

std::string_view
makeProjectRelative(std::string_view pathName) noexcept;

Description

Strips the build‐time project‐root prefix so diagnostics print short, repository‐relative paths (e.g. src/mrdocs/Support/Report.cpp). The root is derived from this translation unit's own location, so it needs no marker file at the repository root. A path that is not under the project root falls back to its bare file name.

The result is a view into pathName (like getFileName), so it is only valid while pathName's storage lives.

Return Value

The portion of pathName relative to the project root, or its bare file name when it is not under the root.

Parameters

Name

Description

pathName

An absolute source path, e.g. from source_location.

Created with MrDocs