• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 26751910360

01 Jun 2026 11:24AM UTC coverage: 52.046% (-40.7%) from 92.792%
26751910360

Pull #23395

github

web-flow
Merge 41608d741 into c8127c1f4
Pull Request #23395: Bump the gha-deps group with 8 updates

31994 of 61473 relevant lines covered (52.05%)

1.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.78
/src/python/pants/util/docutil.py
1
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4

5
from __future__ import annotations
2✔
6

7
import shutil
2✔
8

9
from pants.engine.internals.native_engine import py_bin_name
2✔
10
from pants.version import MAJOR_MINOR, PANTS_SEMVER
2✔
11

12

13
# NB: This is not memoized because that would cause Pants to not pick up terminal resizing when
14
# using pantsd.
15
def terminal_width(*, fallback: int = 96, padding: int = 2) -> int:
2✔
16
    columns = shutil.get_terminal_size(fallback=(fallback, 24)).columns
×
17
    # Some limited terminals may report a width of 0 even when a fallback is provided
18
    # (for example, certain non-interactive environments or misbehaving terminal emulators).
19
    # Treat a reported width of 0 as if the fallback was returned to avoid returning
20
    # an invalid or negative width after applying padding.
21
    if columns == 0:
×
22
        columns = fallback
×
23
    return columns - padding
×
24

25

26
_VERSIONED_PREFIXES = ("docs/", "reference/")
2✔
27

28

29
def doc_url(path: str) -> str:
2✔
30
    """Return a URL to the specified `path` on the Pants website.
31

32
    The path should be the part of the URL after the domain, ignoring the version, e.g.:
33

34
    - to link to https://www.pantsbuild.org/community/getting-help, pass `"/community/getting-help"`
35

36
    - to link to the current version of
37
      https://www.pantsbuild.org/2.19/docs/python/overview/enabling-python-support, pass
38
      `"docs/python/overview/enabling-python-support"`
39
    """
40
    versioned = any(path.startswith(prefix) for prefix in _VERSIONED_PREFIXES)
2✔
41
    version_info = f"{MAJOR_MINOR}/" if versioned else ""
2✔
42
    return f"https://www.pantsbuild.org/{version_info}{path}"
2✔
43

44

45
def git_url(fp: str) -> str:
2✔
46
    """Link to code in pantsbuild/pants."""
47
    return f"https://github.com/pantsbuild/pants/blob/release_{PANTS_SEMVER}/{fp}"
2✔
48

49

50
def bin_name() -> str:
2✔
51
    """Return the Pants binary name, e.g. 'pants'.
52

53
    Can be configured with the pants_bin_name option.
54
    """
55
    return py_bin_name()
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc