epythet.tools.published_docs¶
Elements for a tool to setup docs and check if docs are published, and if not, why.
>>> from epythet.tools.published_docs import published_doc_diagnosis_df
>>> published_doc_diagnosis_df('https://github.com/i2mint/epythet')
url doc_page_url doc_page_exists repo_has_docs_folder
0 https://github.com/i2mint/epythet https://i2mint.github.io/epythet True True
>>> published_doc_diagnosis_df([
... 'https://github.com/i2mint/epythet', 'https://github.com/myorg/myrepo',
... ])
url doc_page_url doc_page_exists repo_has_docs_folder
0 https://github.com/i2mint/epythet https://i2mint.github.io/epythet True True
1 https://github.com/myorg/myrepo https://myorg.github.io/myrepo False False
Functions
|
Check if a branch exists in a repo. |
|
Diagnose the GitHub Pages setup for a single repo. |
|
Check the scopes of a GitHub token. |
|
|
|
Retrieves data about the latest commit on a branch of a GitHub repository. |
|
Configure or update GitHub Pages for a repo. |
|
Configure Pages for an iterable of repo stubs, or all repos in an organization. |
|
Retrieves the default branch and current commit SHA for a given GitHub repository. |
|
|
|
Enable or update GitHub Pages for a repo. |
|
Ensures a branch exists. |
|
|
|
|
|
|
|
|
|
Return the GitHub Pages configuration for a repo, or None if not configured. |
|
The |
|
Retrieves data about a GitHub repository. |
|
Extract the |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- epythet.tools.published_docs.branch_exists(repo_stub, branch, *, headers=<function dflt_headers>, verbose=True)[source]¶
Check if a branch exists in a repo.
- epythet.tools.published_docs.check_pages_setup(repo_stub, *, expected_branch='gh-pages', expected_path='/', check_url=True)[source]¶
Diagnose the GitHub Pages setup for a single repo.
Returns a dict describing the state of things:
{ 'repo': 'owner/repo', 'gh_pages_branch_exists': True/False, 'pages_enabled': True/False, 'source_branch': 'gh-pages' or None, 'source_path': '/' or None, 'correctly_configured': True/False, 'docs_url': 'https://owner.github.io/repo', 'docs_url_responding': True/False or None, # None if not checked 'diagnosis': 'A human-readable summary of what is wrong (or right).', }
Works with either a
GITHUB_TOKENenv var or an authenticatedghCLI.>>> check_pages_setup('i2mint/epythet')
- epythet.tools.published_docs.check_token_scopes(token=None, *, verbose=True)[source]¶
Check the scopes of a GitHub token.
- epythet.tools.published_docs.commit_data(repo_stub, branch, *, headers=<function dflt_headers>)[source]¶
Retrieves data about the latest commit on a branch of a GitHub repository.
- Return type:
- epythet.tools.published_docs.configure_github_pages(repo_stub, *, target_branch='gh-pages', folder='/', ensure_branch_exists=True, headers=<function dflt_headers>, verbose=True)[source]¶
Configure or update GitHub Pages for a repo.
Example
>>> configure_github_pages('i2mint/epythet')
- epythet.tools.published_docs.configure_github_pages_for_repo_stubs(repo_stubs)[source]¶
Configure Pages for an iterable of repo stubs, or all repos in an organization.
>>> repo_pages_status = dict( ... configure_github_pages_for_stubs('i2mint') ... )
- epythet.tools.published_docs.default_branch_and_commit_sha(repo_stub, *, headers=<function dflt_headers>)[source]¶
Retrieves the default branch and current commit SHA for a given GitHub repository.
- epythet.tools.published_docs.enable_pages(repo_stub, *, branch='gh-pages', path='/')[source]¶
Enable or update GitHub Pages for a repo. Uses
ghCLI or GITHUB_TOKEN.This is the recommended way to programmatically set up Pages. Unlike
configure_github_pages(which requiresrequestsand a token), this function works out of the box if you haveghinstalled and authenticated.Returns the API response dict on success, or None on failure.
>>> enable_pages('thorwhalen/denote')
- epythet.tools.published_docs.ensure_branch(repo_stub, *, branch, commit_sha=None, headers=<function dflt_headers>, verbose=True)[source]¶
Ensures a branch exists. Does nothing if it already does, and creates it if not.
- Parameters:
repo_stub (
str) – Owner and name of the GitHub repository, e.g., ‘owner/repo’.branch (
str) – Name of the branch to be created if it doesn’t existcommit_sha (
str) – Commit SHA to base the new branch on. By default, it’s the SHA of the most recent commit of the default branch.headers (
Union[dict,Callable[[],dict]]) – Headers for authentication, e.g., {‘Authorization’: ‘Bearer <token>’}.
- Returns:
Response from GitHub API as a dictionary.
- Return type:
- epythet.tools.published_docs.github_org_and_repo(github_url)[source]¶
>>> github_org_and_repo('https://github.com/i2mint/i2') {'org': 'i2mint', 'repo': 'i2'}
- epythet.tools.published_docs.pages_config(repo_stub)[source]¶
Return the GitHub Pages configuration for a repo, or None if not configured.
Returns a dict with keys like
source(containingbranchandpath),html_url,build_type, etc. ReturnsNonewhen Pages is not enabled.Works with either a
GITHUB_TOKENenv var or an authenticatedghCLI.>>> pages_config('i2mint/epythet') {'source': {'branch': 'gh-pages', 'path': '/'}, 'html_url': '...', ...}
- epythet.tools.published_docs.published_doc_diagnosis_df(urls=None, url_column='url')[source]¶
The
published_doc_diagnosis_dfgets you a pandas dataframe (requires pandas to be installed!) that will tell you if given githuborg/repourl(s) have published documentation and if adocsfolder even exists (in master branch).
- epythet.tools.published_docs.repo_data(repo_stub, *, headers=<function dflt_headers>)[source]¶
Retrieves data about a GitHub repository.
- Return type:
- epythet.tools.published_docs.repo_stub_from_local_dir(path='.')[source]¶
Extract the
owner/reposlug from a local git checkout’s remote URL.>>> repo_stub_from_local_dir('/path/to/some/git/repo') 'owner/repo'