markdown-up 3.3.1__tar.gz → 3.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown-up
3
- Version: 3.3.1
3
+ Version: 3.3.2
4
4
  Summary: MarkdownUp is a Markdown viewer
5
5
  Author-email: "Craig A. Hobbs" <craigahobbs@gmail.com>
6
6
  License-Expression: MIT
@@ -84,19 +84,12 @@ The generated `.html` files are HTML stubs for the
84
84
  All Markdown parsing and rendering are done on the client.
85
85
 
86
86
 
87
- ### Configuration File
88
-
89
- The
90
- [MarkdownUp Application Configuration File](https://craigahobbs.github.io/markdown-up-py/config.html#var.vName='MarkdownUpConfig'),
91
- `markdown-up.json`, allows you to enable release mode, set the number of backend server threads, and more.
92
-
93
-
94
87
  ### Command-Line Arguments
95
88
 
96
89
  The `markdown-up` application has the following command-line arguments:
97
90
 
98
91
  ```
99
- usage: markdown-up [-h] [-p N] [-t N] [-n] [-r] [-q] [-c FILE] [path]
92
+ usage: markdown-up [-h] [-p N] [-t N] [-n] [-r] [-q] [path]
100
93
 
101
94
  positional arguments:
102
95
  path the file or directory to view (default is ".")
@@ -108,7 +101,6 @@ options:
108
101
  -n, --no-browser don't open a web browser
109
102
  -r, --release release mode (cache statics, remove documentation and index)
110
103
  -q, --quiet hide access logging
111
- -c, --config FILE the application config filename (default is "markdown-up.json")
112
104
  ```
113
105
 
114
106
 
@@ -141,7 +133,7 @@ markdownPrint('Hello, **World**!!')
141
133
 
142
134
  ### MarkdownUp Backend Applications
143
135
 
144
- MarkdownUp no longer hosts BareScript backend APIs. To write a backend application in BareScript, use the
136
+ To write a backend application in BareScript, use the
145
137
  [bare-script](https://pypi.org/project/bare-script/) package's
146
138
  [WSGI support](https://craigahobbs.github.io/bare-script-py/wsgi.html).
147
139
 
@@ -59,19 +59,12 @@ The generated `.html` files are HTML stubs for the
59
59
  All Markdown parsing and rendering are done on the client.
60
60
 
61
61
 
62
- ### Configuration File
63
-
64
- The
65
- [MarkdownUp Application Configuration File](https://craigahobbs.github.io/markdown-up-py/config.html#var.vName='MarkdownUpConfig'),
66
- `markdown-up.json`, allows you to enable release mode, set the number of backend server threads, and more.
67
-
68
-
69
62
  ### Command-Line Arguments
70
63
 
71
64
  The `markdown-up` application has the following command-line arguments:
72
65
 
73
66
  ```
74
- usage: markdown-up [-h] [-p N] [-t N] [-n] [-r] [-q] [-c FILE] [path]
67
+ usage: markdown-up [-h] [-p N] [-t N] [-n] [-r] [-q] [path]
75
68
 
76
69
  positional arguments:
77
70
  path the file or directory to view (default is ".")
@@ -83,7 +76,6 @@ options:
83
76
  -n, --no-browser don't open a web browser
84
77
  -r, --release release mode (cache statics, remove documentation and index)
85
78
  -q, --quiet hide access logging
86
- -c, --config FILE the application config filename (default is "markdown-up.json")
87
79
  ```
88
80
 
89
81
 
@@ -116,7 +108,7 @@ markdownPrint('Hello, **World**!!')
116
108
 
117
109
  ### MarkdownUp Backend Applications
118
110
 
119
- MarkdownUp no longer hosts BareScript backend APIs. To write a backend application in BareScript, use the
111
+ To write a backend application in BareScript, use the
120
112
  [bare-script](https://pypi.org/project/bare-script/) package's
121
113
  [WSGI support](https://craigahobbs.github.io/bare-script-py/wsgi.html).
122
114
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "markdown-up"
7
- version = "3.3.1"
7
+ version = "3.3.2"
8
8
  description = "MarkdownUp is a Markdown viewer"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -22,10 +22,10 @@ class MarkdownUpApplication(chisel.Application):
22
22
  __slots__ = ('root', 'release', 'add_request_lock')
23
23
 
24
24
 
25
- def __init__(self, root, config=None):
25
+ def __init__(self, root, release=False):
26
26
  super().__init__()
27
27
  self.root = root
28
- self.release = config.get('release', False) if config else False
28
+ self.release = release
29
29
  self.add_request_lock = threading.Lock()
30
30
 
31
31
  # Release mode?
@@ -7,13 +7,11 @@ The MarkdownUp backend command-line application
7
7
 
8
8
  import argparse
9
9
  from functools import partial
10
- import json
11
10
  import os
12
11
  import sys
13
12
  import threading
14
13
  import webbrowser
15
14
 
16
- from schema_markdown import parse_schema_markdown, validate_type
17
15
  import waitress
18
16
 
19
17
  from .app import HTML_EXTS, MARKDOWN_EXTS, MarkdownUpApplication
@@ -33,16 +31,14 @@ def main(argv=None):
33
31
  help='the file or directory to view (default is ".")')
34
32
  parser.add_argument('-p', '--port', metavar='N', type=int, default=8080,
35
33
  help='the application port (default is 8080)')
36
- parser.add_argument('-t', '--threads', metavar='N', type=int,
34
+ parser.add_argument('-t', '--threads', metavar='N', type=int, default=8,
37
35
  help='the number of web server threads (default is 8)')
38
36
  parser.add_argument('-n', '--no-browser', action='store_true',
39
37
  help="don't open a web browser")
40
- parser.add_argument('-r', '--release', action='store_true', default=None,
38
+ parser.add_argument('-r', '--release', action='store_true',
41
39
  help="release mode (cache statics, remove documentation and index)")
42
40
  parser.add_argument('-q', '--quiet', action='store_true',
43
41
  help="hide access logging")
44
- parser.add_argument('-c', '--config', metavar='FILE', default='markdown-up.json',
45
- help='the application config filename (default is "markdown-up.json")')
46
42
  args = parser.parse_args(args=argv)
47
43
 
48
44
  # Verify the path exists
@@ -61,18 +57,6 @@ def main(argv=None):
61
57
  if root == '':
62
58
  root = '.'
63
59
 
64
- # Load and validate the configuration file
65
- config_path = os.path.normpath(os.path.join(root, args.config))
66
- if os.path.isfile(config_path):
67
- with open(config_path, 'r', encoding='utf-8') as config_file:
68
- config = validate_type(CONFIG_TYPES, 'MarkdownUpConfig', json.load(config_file))
69
- else:
70
- config = {}
71
-
72
- # Add arguments to the config
73
- config['release'] = args.release if args.release is not None else config.get('release', False)
74
- config['threads'] = max(1, args.threads if args.threads is not None else config.get('threads', 8))
75
-
76
60
  # Construct the URL
77
61
  host = '127.0.0.1'
78
62
  if is_file:
@@ -86,19 +70,19 @@ def main(argv=None):
86
70
  url = f'http://{host}:{args.port}/'
87
71
 
88
72
  # Launch the web browser on a thread so the WSGI application can startup first
89
- if not config['release'] and not args.no_browser:
73
+ if not args.release and not args.no_browser:
90
74
  webbrowser_thread = threading.Thread(target=webbrowser.open, args=(url,))
91
75
  webbrowser_thread.daemon = True
92
76
  webbrowser_thread.start()
93
77
 
94
78
  # Create the WSGI application
95
- wsgiapp = MarkdownUpApplication(root, config)
79
+ wsgiapp = MarkdownUpApplication(root, release=args.release)
96
80
  wsgiapp_wrap = wsgiapp if args.quiet else partial(_wsgiapp_log_access, wsgiapp)
97
81
 
98
82
  # Host the application
99
83
  if not args.quiet:
100
84
  print(f'markdown-up: Serving at {url} ...')
101
- waitress.serve(wsgiapp_wrap, port=args.port, threads=config['threads'])
85
+ waitress.serve(wsgiapp_wrap, port=args.port, threads=max(1, args.threads))
102
86
 
103
87
 
104
88
  # WSGI application wrapper and the start_response function so we can log status and environ
@@ -108,19 +92,3 @@ def _wsgiapp_log_access(wsgiapp, environ, start_response):
108
92
  print(f'markdown-up: {status[0:3]} {environ["REQUEST_METHOD"]} {environ["PATH_INFO"]}{query_string}')
109
93
  return start_response(status, response_headers)
110
94
  return wsgiapp(environ, log_start_response)
111
-
112
-
113
- # The backend configuration schema
114
- CONFIG_TYPES = parse_schema_markdown('''\
115
- group "Application Configuration"
116
-
117
-
118
- # The MarkdownUp application configuration (e.g. `markdown-up.json`)
119
- struct MarkdownUpConfig
120
-
121
- # If true, run in release mode. Default is false.
122
- optional bool release
123
-
124
- # The number of backend server threads. Default is 8.
125
- optional int threads
126
- ''')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown-up
3
- Version: 3.3.1
3
+ Version: 3.3.2
4
4
  Summary: MarkdownUp is a Markdown viewer
5
5
  Author-email: "Craig A. Hobbs" <craigahobbs@gmail.com>
6
6
  License-Expression: MIT
@@ -84,19 +84,12 @@ The generated `.html` files are HTML stubs for the
84
84
  All Markdown parsing and rendering are done on the client.
85
85
 
86
86
 
87
- ### Configuration File
88
-
89
- The
90
- [MarkdownUp Application Configuration File](https://craigahobbs.github.io/markdown-up-py/config.html#var.vName='MarkdownUpConfig'),
91
- `markdown-up.json`, allows you to enable release mode, set the number of backend server threads, and more.
92
-
93
-
94
87
  ### Command-Line Arguments
95
88
 
96
89
  The `markdown-up` application has the following command-line arguments:
97
90
 
98
91
  ```
99
- usage: markdown-up [-h] [-p N] [-t N] [-n] [-r] [-q] [-c FILE] [path]
92
+ usage: markdown-up [-h] [-p N] [-t N] [-n] [-r] [-q] [path]
100
93
 
101
94
  positional arguments:
102
95
  path the file or directory to view (default is ".")
@@ -108,7 +101,6 @@ options:
108
101
  -n, --no-browser don't open a web browser
109
102
  -r, --release release mode (cache statics, remove documentation and index)
110
103
  -q, --quiet hide access logging
111
- -c, --config FILE the application config filename (default is "markdown-up.json")
112
104
  ```
113
105
 
114
106
 
@@ -141,7 +133,7 @@ markdownPrint('Hello, **World**!!')
141
133
 
142
134
  ### MarkdownUp Backend Applications
143
135
 
144
- MarkdownUp no longer hosts BareScript backend APIs. To write a backend application in BareScript, use the
136
+ To write a backend application in BareScript, use the
145
137
  [bare-script](https://pypi.org/project/bare-script/) package's
146
138
  [WSGI support](https://craigahobbs.github.io/bare-script-py/wsgi.html).
147
139
 
File without changes
File without changes