mkdocstrings-github 0.2.3__py3-none-any.whl → 0.2.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocstrings-github
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: A GitHub Action handler for mkdocstrings
5
5
  Author-email: Mark Hu <watermarkhu@gmail.com>
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  mkdocstrings_handlers/github/__init__.py,sha256=0WdFUIq4Xu2ZFtlZNIYCQSoqcx3Ot9Wv41_X_dwbFww,248
2
- mkdocstrings_handlers/github/config.py,sha256=pSjA6gU-kC_mXQqNIIGOYEOhtX5VzZDT0H1hRFlGaj8,6089
3
- mkdocstrings_handlers/github/handler.py,sha256=aqrayPGjHONg1IbWxiw-VjgG38qBafW-_xOGww23xMg,9745
2
+ mkdocstrings_handlers/github/config.py,sha256=b2sZiRehEtg27ZUbPmUld8SlsGUYE5f1qLFuq1cWjlU,6220
3
+ mkdocstrings_handlers/github/handler.py,sha256=MD0XmG2vsvsslUpFl1qB6bpiW28jRUNjG2lGkrFNIxs,11251
4
4
  mkdocstrings_handlers/github/objects.py,sha256=qkRGcwwYCHsrc9JEmujnvIt00_B1y5cR0vGS5NRkuSg,7028
5
5
  mkdocstrings_handlers/github/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  mkdocstrings_handlers/github/rendering.py,sha256=8h5Zn62b3od9Dj3MNvMtAGg_ZyyLfJKv2Z2qGdFaKG8,2329
@@ -11,7 +11,7 @@ mkdocstrings_handlers/github/templates/material/outputs.html.jinja,sha256=ePu1v8
11
11
  mkdocstrings_handlers/github/templates/material/secrets.html.jinja,sha256=92ynVoZinsLEp7_sFS3mL2E2ngOXPPAtXzGAuGFvhmY,2782
12
12
  mkdocstrings_handlers/github/templates/material/style.css,sha256=R2hh1RfHwJ6XNT4YQl_txNkNXcPBZJMCBZn5kQEMQ6M,962
13
13
  mkdocstrings_handlers/github/templates/material/workflow.html.jinja,sha256=E1VUi2w7_NDkpS9VNrWRV52hhyhQvnKUrjPbV_j0Qcg,3312
14
- mkdocstrings_github-0.2.3.dist-info/METADATA,sha256=LKUKsU8uYtYxkKOZRZBhhEXu8dkRzUkogDIi4Ve_rus,3125
15
- mkdocstrings_github-0.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- mkdocstrings_github-0.2.3.dist-info/licenses/LICENSE,sha256=5enZtJ4zSp0Ps3jTqFQ4kadcx62BhgTaDNPrXWb3g3E,1069
17
- mkdocstrings_github-0.2.3.dist-info/RECORD,,
14
+ mkdocstrings_github-0.2.4.dist-info/METADATA,sha256=1pzvDfDEgY43O-Itmcg-1OEae8vJNabUf5esgLT28II,3125
15
+ mkdocstrings_github-0.2.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ mkdocstrings_github-0.2.4.dist-info/licenses/LICENSE,sha256=5enZtJ4zSp0Ps3jTqFQ4kadcx62BhgTaDNPrXWb3g3E,1069
17
+ mkdocstrings_github-0.2.4.dist-info/RECORD,,
@@ -171,6 +171,11 @@ class GitHubOptions(BaseModel):
171
171
  class GitHubConfig(BaseModel):
172
172
  """Configuration options for the GitHub handler."""
173
173
 
174
+ hostname: str = Field(
175
+ default="github.com",
176
+ description="The hostname of the GitHub instance to use.",
177
+ )
178
+
174
179
  repo: str = Field(
175
180
  default="",
176
181
  description="""The GitHub repository in the format *owner/repo*.
@@ -80,20 +80,47 @@ class GitHubHandler(BaseHandler):
80
80
  ) and "pytest" not in sys.modules:
81
81
  # Use PyGitHub to find last GitHub releases with tags matching vX.X.X and vX
82
82
 
83
- GH_HOST = os.environ.get("GH_HOST", "https://api.github.com")
83
+ gh_host = os.environ.get("GH_HOST", config.hostname)
84
+ # Construct base_url for GitHub API.
85
+ #
86
+ # Expected formats for GH_HOST/config.hostname:
87
+ # - Full API URL (e.g., 'https://github.company.com/api/v3') [RECOMMENDED for GitHub Enterprise]
88
+ # - Hostname (e.g., 'github.com' or 'github.company.com')
89
+ # - API subdomain (e.g., 'api.github.com')
90
+ #
91
+ # If a full URL is provided, it is used as-is.
92
+ # If the value contains '/api/', it is assumed to be a full API endpoint and used as-is (with protocol if missing).
93
+ # Otherwise, the code falls back to public GitHub conventions.
94
+ if gh_host.startswith(("http://", "https://")):
95
+ base_url = gh_host
96
+ elif "/api/" in gh_host:
97
+ # If protocol is missing, default to https
98
+ base_url = f"https://{gh_host}"
99
+ elif gh_host.startswith("api."):
100
+ base_url = f"https://{gh_host}"
101
+ else:
102
+ # Warn user about possible misconfiguration for GitHub Enterprise
103
+ _logger.warning(
104
+ "The GH_HOST/config.hostname value '%s' does not appear to be a full API endpoint. "
105
+ "For GitHub Enterprise, you may need to specify the full API URL (e.g., 'https://github.company.com/api/v3').",
106
+ gh_host,
107
+ )
108
+ base_url = f"https://api.{gh_host}"
84
109
 
85
110
  if (token_key := "GH_TOKEN") in os.environ:
86
- gh = Github(base_url=GH_HOST, auth=Auth.Token(os.environ[token_key]))
111
+ gh = Github(base_url=base_url, auth=Auth.Token(os.environ[token_key]))
87
112
  elif (token_key := "GITHUB_TOKEN") in os.environ:
88
- gh = Github(base_url=GH_HOST, auth=Auth.Token(os.environ[token_key]))
113
+ gh = Github(base_url=base_url, auth=Auth.Token(os.environ[token_key]))
89
114
  else:
90
115
  try:
91
- gh = Github(base_url=GH_HOST, auth=Auth.NetrcAuth())
116
+ gh = Github(base_url=base_url, auth=Auth.NetrcAuth())
92
117
  except RuntimeError:
93
118
  try:
94
- token = subprocess.check_output(["gh", "auth", "token"], text=True).strip()
119
+ token = subprocess.check_output(
120
+ ["gh", "auth", "token"], text=True, env=os.environ
121
+ ).strip()
95
122
  if token:
96
- gh = Github(base_url=GH_HOST, auth=Auth.Token(token))
123
+ gh = Github(base_url=base_url, auth=Auth.Token(token))
97
124
  else:
98
125
  raise RuntimeError("No token from gh auth token")
99
126
  except Exception:
@@ -102,7 +129,7 @@ class GitHubHandler(BaseHandler):
102
129
  "Consider setting .netrc, environment variable GH_TOKEN, "
103
130
  "or using GitHub CLI (`gh auth login`) to get GitHub releases.",
104
131
  )
105
- gh = Github(base_url=GH_HOST)
132
+ gh = Github(base_url=base_url)
106
133
 
107
134
  owner, repo_name = self.config.repo.split("/", 1)
108
135
  gh_repo = gh.get_repo(f"{owner}/{repo_name}")