Eclectic Media Git toast-with_toast_when_complete / 7ae9956
Added commands to handle docs to setup.py, added requirements Ariana Giroux 1 year, 1 month ago
3 changed file(s) with 99 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
0 sphinx
1 click
2 fabric>=
00 [aliases]
11 test=pytest
2 help=docs
00 from setuptools import setup, find_packages
1 from pingstats import __version__
1 from distutils.cmd import Command
2 from sphinx.setup_command import BuildDoc
3 from sys import executable
4 from os import system, access, F_OK
25
3 # with open("README.rst", "r") as fh:
4 # long_description = fh.read()
6 with open("Readme.rst", "r") as fh:
7 long_description = fh.read()
58
6 # with open("requirements.txt", "r") as f:
7 # required = f.read().splitlines()
9 with open("requirements.txt", "r") as f:
10 required = f.read().splitlines()
11
12
13 class Docs(Command):
14 user_options = [
15 ('manpage=', None, 'The man page section you want to view (likely 5)'),
16 ('compile', None, 'Force recompile of the docs'),
17 ]
18
19 def initialize_options(self):
20 self.manpage = '1'
21 self.compile = False
22
23 def finalize_options(self):
24 try:
25 int(self.manpage)
26 except ValueError:
27 print('--manpage must be an int between 1 and 8')
28 exit(1)
29
30 def run(self):
31 if not access('docs/build/man', F_OK) or self.compile:
32 self.announce('Compiling docs...', level=4)
33 system('%s setup.py build_sphinx' % executable)
34
35 if self.manpage == '':
36 system('man ./docs/build/man/toast.1')
37 else:
38 system('man ./docs/build/man/toast.%s' % self.manpage)
39
40
41 class InstallDocs(Command):
42 user_options = [
43 ('system-wide', None, 'Install pages system wide'),
44 ]
45
46 def initialize_options(self):
47 self.system_wide = False
48
49 def finalize_options(self):
50 pass
51
52 def run(self):
53 self.announce('Compiling docs...')
54 system('%s setup.py build_sphinx' % executable)
55 self.announce('Installing docs')
56 system('mkdir -p ~/.local/man/man1 ~/.local/man/man5')
57 system('cp docs/build/man/toast.1 ~/.local/man/man1/')
58 system('cp docs/build/man/toast.5 ~/.local/man/man5/')
59 system('mandb')
60
61
62 class UninstallDocs(Command):
63 user_options = [
64 ('system-wide', None, 'Install pages system wide'),
65 ]
66
67 def initialize_options(self):
68 self.system_wide = False
69
70 def finalize_options(self):
71 pass
72
73 def run(self):
74 self.announce('Uninstalling manpages')
75 system('rm ~/.local/man/man1/toast.1')
76 system('rm ~/.local/man/man5/toast.5')
77 system('mandb')
78
879
980 setup(
1081 name='toast',
11 version=__version__,
12 description='Simple ping visualization on the CLI',
13 # long_description=long_description,
14 # long_description_content_type="text/x-rst",
15 # install_requires=required,
82 version=0.1,
83 description='WSL Access to Windows toast notifications',
84 long_description=long_description,
85 long_description_content_type="text/x-rst",
86 install_requires=required,
1687 url='git-server:arianagiroux/toast.git',
1788 author='Ariana Giroux',
1889 author_email='ariana.giroux@gmail.com',
2495 entry_points={
2596 'console_scripts': ['toast=toast.__main__'],
2697 },
98 cmdclass={
99 'build_sphinx': BuildDoc,
100 'docs': Docs,
101 'install_docs': InstallDocs,
102 'uninstall_docs': UninstallDocs,
103 },
104 command_options={
105 'build_sphinx': {
106 'project': ('setup.py', 'toast'),
107 'version': ('setup.py', '0.1'),
108 'source_dir': ('setup.py', 'docs'),
109 'build_dir': ('setup.py', 'docs/build'),
110 'builder': ('setup.py', 'man'),
111 }},
27112 classifiers=(
28113 "Programming Language :: Python :: 3",
29114 "License :: OSI Approved :: MIT License",