forked from pool/python-click-man
Accepting request 754089 from home:seanmarlow:branches:devel:languages:python
Initial release. Add click-man v0.3.0 for auto generating man pages for click applications. Patch is submitted upstream https://github.com/click-contrib/click-man/pull/33. OBS-URL: https://build.opensuse.org/request/show/754089 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-click-man?expand=0&rev=1
This commit is contained in:
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
## Default LFS
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.osc
|
||||
3
click-man-0.3.0.tar.gz
Normal file
3
click-man-0.3.0.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b3c36982f4607d58272667d05ce75c41321b7e5a926c6f9183b3ba9eebe9f075
|
||||
size 462653
|
||||
36
get-short-help.patch
Normal file
36
get-short-help.patch
Normal file
@@ -0,0 +1,36 @@
|
||||
Index: click-man-0.3.0/click_man/core.py
|
||||
===================================================================
|
||||
--- click-man-0.3.0.orig/click_man/core.py
|
||||
+++ click-man-0.3.0/click_man/core.py
|
||||
@@ -17,6 +17,14 @@ from .man import ManPage
|
||||
|
||||
CLICK_VERSION = tuple(int(x) for x in click.__version__.split('.'))
|
||||
|
||||
+
|
||||
+def get_short_help_str(command, limit=45):
|
||||
+ """
|
||||
+ Gets short help for the command or makes it by shortening the long help string.
|
||||
+ """
|
||||
+ return command.short_help or command.help and click.utils.make_default_short_help(command.help, limit) or ''
|
||||
+
|
||||
+
|
||||
def generate_man_page(ctx, version=None):
|
||||
"""
|
||||
Generate documentation for the given command.
|
||||
@@ -30,14 +38,14 @@ def generate_man_page(ctx, version=None)
|
||||
# Create man page with the details from the given context
|
||||
man_page = ManPage(ctx.command_path)
|
||||
man_page.version = version
|
||||
- man_page.short_help = ctx.command.get_short_help_str()
|
||||
+ man_page.short_help = get_short_help_str(ctx.command)
|
||||
man_page.description = ctx.command.help
|
||||
man_page.synopsis = ' '.join(ctx.command.collect_usage_pieces(ctx))
|
||||
man_page.options = [x.get_help_record(None) for x in ctx.command.params if isinstance(x, click.Option)]
|
||||
commands = getattr(ctx.command, 'commands', None)
|
||||
if commands:
|
||||
man_page.commands = [
|
||||
- (k, v.get_short_help_str()) for k, v in commands.items()
|
||||
+ (k, get_short_help_str(v)) for k, v in commands.items()
|
||||
]
|
||||
|
||||
return str(man_page)
|
||||
8
python-click-man.changes
Normal file
8
python-click-man.changes
Normal file
@@ -0,0 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Nov 25 20:45:00 UTC 2019 - Sean Marlow <sean.marlow@suse.com>
|
||||
|
||||
- Initial release. v0.3.0
|
||||
- get-short-help.patch adds get_short_help_str function and
|
||||
supports older versions of python-click. get_short_help_str was
|
||||
added to Click in version >= 7.0.0.
|
||||
- Use pytest instead of nose for unit tests.
|
||||
71
python-click-man.spec
Normal file
71
python-click-man.spec
Normal file
@@ -0,0 +1,71 @@
|
||||
#
|
||||
# spec file for package python-click-man
|
||||
#
|
||||
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
# upon. The license for this file, and modifications and additions to the
|
||||
# file, is the same license as for the pristine package itself (unless the
|
||||
# license for the pristine package is not an Open Source License, in which
|
||||
# case the license is the MIT License). An "Open Source License" is a
|
||||
# license that conforms to the Open Source Definition (Version 1.9)
|
||||
# published by the Open Source Initiative.
|
||||
|
||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||
Name: python-click-man
|
||||
Version: 0.3.0
|
||||
Release: 0
|
||||
Summary: Automate generation of man pages for python click applications
|
||||
License: MIT
|
||||
Url: https://github.com/click-contrib/click-man
|
||||
Source: https://files.pythonhosted.org/packages/source/C/click-man/click-man-%{version}.tar.gz
|
||||
Patch1: get-short-help.patch
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: %{python_module click}
|
||||
BuildRequires: %{python_module pytest}
|
||||
BuildRequires: %{python_module sure}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
Requires: python-click
|
||||
BuildArch: noarch
|
||||
%python_subpackages
|
||||
|
||||
%description
|
||||
Automate generation of man pages for Python Click applications.
|
||||
|
||||
%prep
|
||||
%setup -q -n click-man-%{version}
|
||||
%patch1 -p1
|
||||
|
||||
%build
|
||||
export LANG=en_US.UTF-8
|
||||
%python_build
|
||||
|
||||
%install
|
||||
export LANG=en_US.UTF-8
|
||||
%python_install
|
||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||
%python_clone -a %{buildroot}%{_bindir}/click-man
|
||||
|
||||
%check
|
||||
export LANG=en_US.UTF-8
|
||||
%pytest
|
||||
|
||||
%post
|
||||
%python_install_alternative click-man
|
||||
|
||||
%postun
|
||||
%python_uninstall_alternative click-man
|
||||
|
||||
%files %{python_files}
|
||||
%license LICENSE
|
||||
%doc CHANGELOG.md README.md
|
||||
%python_alternative %{_bindir}/click-man
|
||||
%{python_sitelib}/*
|
||||
|
||||
%changelog
|
||||
|
||||
Reference in New Issue
Block a user