def _from_git(distribution): option_dict = distribution.get_option_dict('pbr') changelog = git._iter_log_oneline() if changelog: changelog = git._iter_changelog(changelog) git.write_git_changelog(option_dict=option_dict, changelog=changelog) git.generate_authors(option_dict=option_dict)
def run(self): option_dict = self.distribution.get_option_dict('pbr') if git._git_is_installed(): git.write_git_changelog(option_dict=option_dict) git.generate_authors(option_dict=option_dict) tree_index = options.get_boolean_option(option_dict, 'autodoc_tree_index_modules', 'AUTODOC_TREE_INDEX_MODULES') auto_index = options.get_boolean_option(option_dict, 'autodoc_index_modules', 'AUTODOC_INDEX_MODULES') if not os.getenv('SPHINX_DEBUG'): # NOTE(afazekas): These options can be used together, # but they do a very similar thing in a different way if tree_index: self._sphinx_tree() if auto_index: self.generate_autoindex( set(option_dict.get( "autodoc_exclude_modules", [None, ""])[1].split())) for builder in self.builders: self.builder = builder self.finalize_options() self.project = self.distribution.get_name() self.version = self.distribution.get_version() self.release = self.distribution.get_version() if options.get_boolean_option(option_dict, 'warnerrors', 'WARNERRORS'): self._sphinx_run() else: setup_command.BuildDoc.run(self)
def run(self): option_dict = self.distribution.get_option_dict('pbr') if git._git_is_installed(): git.write_git_changelog(option_dict=option_dict) git.generate_authors(option_dict=option_dict) tree_index = options.get_boolean_option(option_dict, 'autodoc_tree_index_modules', 'AUTODOC_TREE_INDEX_MODULES') auto_index = options.get_boolean_option(option_dict, 'autodoc_index_modules', 'AUTODOC_INDEX_MODULES') if not os.getenv('SPHINX_DEBUG'): # NOTE(afazekas): These options can be used together, # but they do a very similar thing in a different way if tree_index: self._sphinx_tree() if auto_index: self.generate_autoindex( set( option_dict.get("autodoc_exclude_modules", [None, ""])[1].split())) for builder in self.builders: self.builder = builder self.finalize_options() self.project = self.distribution.get_name() self.version = self.distribution.get_version() self.release = self.distribution.get_version() if options.get_boolean_option(option_dict, 'warnerrors', 'WARNERRORS'): self._sphinx_run() else: setup_command.BuildDoc.run(self)
def run(self): option_dict = self.distribution.get_option_dict('pbr') if git._git_is_installed(): git.write_git_changelog(option_dict=option_dict) git.generate_authors(option_dict=option_dict) tree_index = options.get_boolean_option(option_dict, 'autodoc_tree_index_modules', 'AUTODOC_TREE_INDEX_MODULES') auto_index = options.get_boolean_option(option_dict, 'autodoc_index_modules', 'AUTODOC_INDEX_MODULES') if not os.getenv('SPHINX_DEBUG'): # NOTE(afazekas): These options can be used together, # but they do a very similar thing in a different way if tree_index: self._sphinx_tree() if auto_index: self.generate_autoindex( set(option_dict.get( "autodoc_exclude_modules", [None, ""])[1].split())) # TODO(stephenfin): Deprecate this functionality once we depend on # Sphinx 1.6, which includes a similar feature, in g-r # https://github.com/sphinx-doc/sphinx/pull/3476 self.finalize_options() if hasattr(self, "builder_target_dirs"): # Sphinx >= 1.6.1 return setup_command.BuildDoc.run(self) # Sphinx < 1.6 for builder in self.builders: self.builder = builder self.finalize_options() self._sphinx_run()
def run(self): option_dict = self.distribution.get_option_dict('pbr') changelog = git._iter_log_oneline(option_dict=option_dict) if changelog: changelog = git._iter_changelog(changelog) git.write_git_changelog(option_dict=option_dict, changelog=changelog) git.generate_authors(option_dict=option_dict) # sdist.sdist is an old style class, can't use super() sdist.sdist.run(self)
def run(self): option_dict = self.distribution.get_option_dict('pbr') if git._git_is_installed(): git.write_git_changelog(option_dict=option_dict) git.generate_authors(option_dict=option_dict) tree_index = options.get_boolean_option(option_dict, 'autodoc_tree_index_modules', 'AUTODOC_TREE_INDEX_MODULES') auto_index = options.get_boolean_option(option_dict, 'autodoc_index_modules', 'AUTODOC_INDEX_MODULES') if not os.getenv('SPHINX_DEBUG'): # NOTE(afazekas): These options can be used together, # but they do a very similar thing in a different way if tree_index: self._sphinx_tree() if auto_index: self.generate_autoindex( set(option_dict.get( "autodoc_exclude_modules", [None, ""])[1].split())) self.finalize_options() is_multibuilder_sphinx = version.SemanticVersion.from_pip_string( sphinx.__version__) >= version.SemanticVersion(1, 6) # TODO(stephenfin): Remove support for Sphinx < 1.6 in 4.0 if not is_multibuilder_sphinx: log.warn('[pbr] Support for Sphinx < 1.6 will be dropped in ' 'pbr 4.0. Upgrade to Sphinx 1.6+') # TODO(stephenfin): Remove this at the next MAJOR version bump if self.builders != ['html']: log.warn("[pbr] Sphinx 1.6 added native support for " "specifying multiple builders in the " "'[sphinx_build] builder' configuration option, " "found in 'setup.cfg'. As a result, the " "'[sphinx_build] builders' option has been " "deprecated and will be removed in pbr 4.0. Migrate " "to the 'builder' configuration option.") if is_multibuilder_sphinx: self.builder = self.builders if is_multibuilder_sphinx: # Sphinx >= 1.6 return setup_command.BuildDoc.run(self) # Sphinx < 1.6 for builder in self.builder: self.builder = builder self.finalize_options() self._sphinx_run()
def run(self): option_dict = self.distribution.get_option_dict('pbr') if git._git_is_installed(): git.write_git_changelog(option_dict=option_dict) git.generate_authors(option_dict=option_dict) tree_index = options.get_boolean_option(option_dict, 'autodoc_tree_index_modules', 'AUTODOC_TREE_INDEX_MODULES') auto_index = options.get_boolean_option(option_dict, 'autodoc_index_modules', 'AUTODOC_INDEX_MODULES') if not os.getenv('SPHINX_DEBUG'): # NOTE(afazekas): These options can be used together, # but they do a very similar thing in a different way if tree_index: self._sphinx_tree() if auto_index: self.generate_autoindex( set( option_dict.get("autodoc_exclude_modules", [None, ""])[1].split())) self.finalize_options() is_multibuilder_sphinx = version.SemanticVersion.from_pip_string( sphinx.__version__) >= version.SemanticVersion(1, 6) # TODO(stephenfin): Remove support for Sphinx < 1.6 in 4.0 if not is_multibuilder_sphinx: log.warning('[pbr] Support for Sphinx < 1.6 will be dropped in ' 'pbr 4.0. Upgrade to Sphinx 1.6+') # TODO(stephenfin): Remove this at the next MAJOR version bump if self.builders != ['html']: log.warning("[pbr] Sphinx 1.6 added native support for " "specifying multiple builders in the " "'[sphinx_build] builder' configuration option, " "found in 'setup.cfg'. As a result, the " "'[sphinx_build] builders' option has been " "deprecated and will be removed in pbr 4.0. Migrate " "to the 'builder' configuration option.") if is_multibuilder_sphinx: self.builder = self.builders if is_multibuilder_sphinx: # Sphinx >= 1.6 return setup_command.BuildDoc.run(self) # Sphinx < 1.6 for builder in self.builder: self.builder = builder self.finalize_options() self._sphinx_run()
def test_generate_authors(self): author_old = u"Foo Foo <*****@*****.**>" author_new = u"Bar Bar <*****@*****.**>" co_author = u"Foo Bar <*****@*****.**>" co_author_by = u"Co-authored-by: " + co_author git_log_cmd = ("git --git-dir=%s log --format=%%aN <%%aE>" % self.git_dir) git_co_log_cmd = ("git --git-dir=%s log" % self.git_dir) git_top_level = "git rev-parse --show-toplevel" cmd_map = { git_log_cmd: author_new, git_co_log_cmd: co_author_by, git_top_level: self.root_dir, } exist_files = [ self.git_dir, os.path.join(self.temp_path, "AUTHORS.in") ] self.useFixture( fixtures.MonkeyPatch( "os.path.exists", lambda path: os.path.abspath(path) in exist_files)) def _fake_run_shell_command(cmd, **kwargs): return cmd_map[" ".join(cmd)] self.useFixture( fixtures.MonkeyPatch("pbr.git._run_shell_command", _fake_run_shell_command)) with open(os.path.join(self.temp_path, "AUTHORS.in"), "w") as auth_fh: auth_fh.write("%s\n" % author_old) git.generate_authors(git_dir=self.git_dir, dest_dir=self.temp_path) with open(os.path.join(self.temp_path, "AUTHORS"), "r") as auth_fh: authors = auth_fh.read() self.assertTrue(author_old in authors) self.assertTrue(author_new in authors) self.assertTrue(co_author in authors)
def test_generate_authors(self): author_old = u"Foo Foo <*****@*****.**>" author_new = u"Bar Bar <*****@*****.**>" co_author = u"Foo Bar <*****@*****.**>" co_author_by = u"Co-authored-by: " + co_author git_log_cmd = ( "git --git-dir=%s log --format=%%aN <%%aE>" % self.git_dir) git_co_log_cmd = ("git --git-dir=%s log" % self.git_dir) git_top_level = "git rev-parse --show-toplevel" cmd_map = { git_log_cmd: author_new, git_co_log_cmd: co_author_by, git_top_level: self.root_dir, } exist_files = [self.git_dir, os.path.join(self.temp_path, "AUTHORS.in")] self.useFixture(fixtures.MonkeyPatch( "os.path.exists", lambda path: os.path.abspath(path) in exist_files)) def _fake_run_shell_command(cmd, **kwargs): return cmd_map[" ".join(cmd)] self.useFixture(fixtures.MonkeyPatch( "pbr.git._run_shell_command", _fake_run_shell_command)) with open(os.path.join(self.temp_path, "AUTHORS.in"), "w") as auth_fh: auth_fh.write("%s\n" % author_old) git.generate_authors(git_dir=self.git_dir, dest_dir=self.temp_path) with open(os.path.join(self.temp_path, "AUTHORS"), "r") as auth_fh: authors = auth_fh.read() self.assertTrue(author_old in authors) self.assertTrue(author_new in authors) self.assertTrue(co_author in authors)
def run(self): option_dict = self.distribution.get_option_dict('pbr') # TODO(stephenfin): Remove this (and the entire file) when 5.0 is # released warn_opts = set(option_dict.keys()).intersection(_deprecated_options) warn_env = list(filter(lambda x: os.getenv(x), _deprecated_envs)) if warn_opts or warn_env: msg = ('The autodoc and autodoc_tree features are deprecated in ' '4.2 and will be removed in a future release. You should ' 'use the sphinxcontrib-apidoc Sphinx extension instead. ' 'Refer to the pbr documentation for more information.') if warn_opts: msg += ' Deprecated options: %s' % list(warn_opts) if warn_env: msg += ' Deprecated environment variables: %s' % warn_env log.warn(msg) if git._git_is_installed(): git.write_git_changelog(option_dict=option_dict) git.generate_authors(option_dict=option_dict) tree_index = options.get_boolean_option(option_dict, 'autodoc_tree_index_modules', 'AUTODOC_TREE_INDEX_MODULES') auto_index = options.get_boolean_option(option_dict, 'autodoc_index_modules', 'AUTODOC_INDEX_MODULES') if not os.getenv('SPHINX_DEBUG'): # NOTE(afazekas): These options can be used together, # but they do a very similar thing in a different way if tree_index: self._sphinx_tree() if auto_index: self.generate_autoindex( set(option_dict.get( "autodoc_exclude_modules", [None, ""])[1].split())) self.finalize_options() is_multibuilder_sphinx = version.SemanticVersion.from_pip_string( sphinx.__version__) >= version.SemanticVersion(1, 6) # TODO(stephenfin): Remove support for Sphinx < 1.6 in 4.0 if not is_multibuilder_sphinx: log.warn('[pbr] Support for Sphinx < 1.6 will be dropped in ' 'pbr 4.0. Upgrade to Sphinx 1.6+') # TODO(stephenfin): Remove this at the next MAJOR version bump if self.builders != ['html']: log.warn("[pbr] Sphinx 1.6 added native support for " "specifying multiple builders in the " "'[sphinx_build] builder' configuration option, " "found in 'setup.cfg'. As a result, the " "'[sphinx_build] builders' option has been " "deprecated and will be removed in pbr 4.0. Migrate " "to the 'builder' configuration option.") if is_multibuilder_sphinx: self.builder = self.builders if is_multibuilder_sphinx: # Sphinx >= 1.6 return setup_command.BuildDoc.run(self) # Sphinx < 1.6 for builder in self.builders: self.builder = builder self.finalize_options() self._sphinx_run()
def run(self): option_dict = self.distribution.get_option_dict('pbr') git.write_git_changelog(option_dict=option_dict) git.generate_authors(option_dict=option_dict) # sdist.sdist is an old style class, can't use super() sdist.sdist.run(self)