Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_on_github_pages(mocker, project_dir, chdir):
with chdir(project_dir):
mocker.patch("mkdocs.commands.gh_deploy.gh_deploy")
api.on_github_pages()
mkdocs.commands.gh_deploy.gh_deploy.assert_called_once()
def deploy(args):
"""
Deploy to Github Pages
Args:
args (argparse.Namespace): A Namespace object contaning all the command line arguments
Raises:
exceptions.ConfigurationError
"""
try:
cfg = config.load_config(config_file=args.config_file, remote_branch=args.remote_branch, remote_name=args.remote_name)
gh_deploy.gh_deploy(cfg, message=args.message, force=args.force, ignore_version=args.ignore_version)
except exceptions.ConfigurationError as e:
raise SystemExit('\n' + str(e))
def gh_deploy_command(clean, message, remote_branch, remote_name, force, ignore_version, **kwargs):
"""Deploy your documentation to GitHub Pages"""
try:
cfg = config.load_config(
remote_branch=remote_branch,
remote_name=remote_name,
**kwargs
)
build.build(cfg, dirty=not clean)
gh_deploy.gh_deploy(cfg, message=message, force=force, ignore_version=ignore_version)
except exceptions.ConfigurationError as e: # pragma: no cover
# Avoid ugly, unhelpful traceback
raise SystemExit('\n' + str(e))
def handle_mkdocs_ghdeploy(to_ghdeploy, kind, remote):
if to_ghdeploy:
delete_branch('gh-pages')
cfg = config.load_config(
config_file=os.path.join(CWD, select_config(kind)),
remote_name=remote
)
build.build(cfg)
print('Deploying {} Github Pages to {}#gh-pages'.format(kind, remote))
gh_deploy.gh_deploy(cfg, force=True)
"""Regenerates and deploys the documentation to GitHub pages.
- *directory*: The root folder of your project.
- *config_file*: The [TOML](https://github.com/toml-lang/toml#toml) formatted
config file you wish to use.
- *message*: The commit message to use when uploading your documentation.
- *force*: Force the push to the repository.
- *ignore_version*: Ignore check that build is not being deployed with an old version.
- *modules*: One or more modules to render reference documentation for
"""
directory = directory if directory else os.getcwd()
project_config = project_configuration(directory, config_file, modules)
with render.documentation_in_temp_folder(project_config):
conf = render._mkdocs_config(project_config["mkdocs"])
conf.config_file_path = directory
mkdocs.commands.gh_deploy.gh_deploy(
conf, message=message, force=force, ignore_version=ignore_version
)
print(logo.ascii_art)
print("Documentation successfully generated and pushed!")