Make a text file with the git version.
(app, exception)
| 1732 | |
| 1733 | |
| 1734 | def make_version(app, exception): |
| 1735 | """Make a text file with the git version.""" |
| 1736 | if not ( |
| 1737 | isinstance(app.builder, sphinx.builders.html.StandaloneHTMLBuilder) |
| 1738 | and exception is None |
| 1739 | ): |
| 1740 | return |
| 1741 | try: |
| 1742 | stdout, _ = run_subprocess(["git", "rev-parse", "HEAD"], verbose=False) |
| 1743 | except Exception as exc: |
| 1744 | sphinx_logger.warning(f"Failed to write _version.txt: {exc}") |
| 1745 | return |
| 1746 | with open(os.path.join(app.outdir, "_version.txt"), "w") as fid: |
| 1747 | fid.write(stdout) |
| 1748 | sphinx_logger.info(f'Added "{stdout.rstrip()}" > _version.txt') |
| 1749 | |
| 1750 | |
| 1751 | # -- Connect our handlers to the main Sphinx app --------------------------- |
nothing calls this directly
no test coverage detected