Skip to main content

mdxify.source_links

Utilities for generating source code links.

Functions

detect_github_repo_url

Detect GitHub repository URL from git remote.

get_relative_path

Get the relative path from the repository root to the source file. Args:
  • file_path: Absolute path to the source file
  • root_module: The root module name (e.g., ‘prefect’, ‘fastmcp’)
Returns:
  • Relative path from repo root, or None if unable to determine
Generate a GitHub source code link. Args:
  • repo_url: GitHub repository URL (e.g., https://github.com/owner/repo)
  • branch: Git branch name
  • file_path: Path to the source file
  • line_number: Line number in the source file
  • root_module: Root module name for finding relative paths
Returns:
  • GitHub URL to the specific line, or None if unable to generate
Add a source link to a markdown header. Args:
  • header: The markdown header (e.g., ”### function_name”)
  • source_link: The source code URL
  • link_text: Text for the link (default: “[source]”)
Returns:
  • Header with inline source link icon