Skip to content

Commit

Permalink
Merge pull request #53 from SimplyKnownAsG/master
Browse files Browse the repository at this point in the history
Added __main__.py to execute package with `python -m restview`
  • Loading branch information
mgedmin committed May 3, 2018
2 parents 3d3b286 + 17c28c8 commit cfb57e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
2.8.2 (unreleased)
------------------

- Nothing changed yet.
- Added ``__main__.py`` module to allow package to be executable with
``python -m restview``. - SimplyKnownAsG


2.8.1 (2018-01-28)
Expand Down
7 changes: 7 additions & 0 deletions src/restview/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
This module contains the entry point to restview.
"""
from restview.restviewhttp import main

if __name__ == '__main__':
main()
22 changes: 1 addition & 21 deletions src/restview/restviewhttp.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
#!/usr/bin/python
"""
HTTP-based ReStructuredText viewer.
Usage:
restview [options] filename.rst [...]
or
restview [options] directory [...]
or
restview [options] -e "command" [--watch filename] [...]
or
restview [options] --long-description
or
restview --help
Needs docutils and a web browser. Will syntax-highlight code or doctest blocks
(needs pygments).
"""
from __future__ import print_function

Expand Down Expand Up @@ -682,11 +667,10 @@ def launch_browser(url):


def main():
progname = os.path.basename(sys.argv[0])
parser = argparse.ArgumentParser(
usage="%(prog)s [options] root [...]",
description="Serve ReStructuredText files over HTTP.",
prog=progname)
prog="restview")
parser.add_argument('root',
help='filename or directory to serve documents from',
nargs='*')
Expand Down Expand Up @@ -792,7 +776,3 @@ def main():
pass
finally:
server.close()


if __name__ == '__main__':
main()

0 comments on commit cfb57e3

Please sign in to comment.