jerome-white commited on
Commit
6eea004
1 Parent(s): 9aa1c9e

Correction to documentation reader

Browse files

Python Path class does not retain suffix when using with_name.

Files changed (1) hide show
  1. app.py +19 -3
app.py CHANGED
@@ -171,17 +171,33 @@ def cplot(df, ci=0.95):
171
 
172
  return _plot
173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  #
175
  #
176
  #
177
  with gr.Blocks() as demo:
178
  df = load('jerome-white/alpaca-bt-stan')
179
- docs = Path('docs', ' ').with_suffix('.md')
180
 
181
  gr.Markdown('# Alpaca Bradley–Terry')
182
  with gr.Row():
183
  with gr.Column():
184
- gr.Markdown(docs.with_name('readme').read_text())
185
 
186
  with gr.Column():
187
  plotter = RankPlotter(df)
@@ -224,6 +240,6 @@ with gr.Blocks() as demo:
224
  button.click(cplot(df), inputs=inputs, outputs=[display])
225
 
226
  with gr.Accordion('Disclaimer', open=False):
227
- gr.Markdown(docs.with_name('disclaimer').read_text())
228
 
229
  demo.launch()
 
171
 
172
  return _plot
173
 
174
+ #
175
+ #
176
+ #
177
+ class DocumentationReader:
178
+ _suffix = '.md'
179
+
180
+ def __init__(self, root):
181
+ self.root = root
182
+
183
+ def __getitem__(self, item):
184
+ return (self
185
+ .root
186
+ .joinpath(item)
187
+ .with_suffix(self._suffix)
188
+ .read_text())
189
+
190
  #
191
  #
192
  #
193
  with gr.Blocks() as demo:
194
  df = load('jerome-white/alpaca-bt-stan')
195
+ docs = DocumentationReader('docs')
196
 
197
  gr.Markdown('# Alpaca Bradley–Terry')
198
  with gr.Row():
199
  with gr.Column():
200
+ gr.Markdown(docs['readme'])
201
 
202
  with gr.Column():
203
  plotter = RankPlotter(df)
 
240
  button.click(cplot(df), inputs=inputs, outputs=[display])
241
 
242
  with gr.Accordion('Disclaimer', open=False):
243
+ gr.Markdown(docs['disclaimer'])
244
 
245
  demo.launch()