55from click .core import Command , Context
66from click .formatting import HelpFormatter
77from watson import cli as watson_cli
8+
89# from watson import watson
910
1011
1112class MarkdownFormatter (HelpFormatter ):
12-
1313 def write_heading (self , heading ):
1414 """Writes a heading into the buffer."""
15- self .write (' ### {}\n ' .format (heading ))
15+ self .write (" ### {}\n " .format (heading ))
1616
17- def write_usage (self , prog , args = '' , prefix = ' Usage: ' ):
17+ def write_usage (self , prog , args = "" , prefix = " Usage: " ):
1818 """Writes a usage line into the buffer.
1919 :param prog: the program name.
2020 :param args: whitespace separated list of arguments.
2121 :param prefix: the prefix for the first line.
2222 """
23- self .write (' ```bash\n {} {} {}\n ```\n ' .format (prefix , prog , args ))
23+ self .write (" ```bash\n {} {} {}\n ```\n " .format (prefix , prog , args ))
2424
2525 def write_text (self , text ):
26- """Writes re-indented text into the buffer.
27- """
26+ """Writes re-indented text into the buffer."""
2827
2928 should_indent = False
3029 rows = []
3130
32- for row in text .split (' \n ' ):
31+ for row in text .split (" \n " ):
3332
3433 if should_indent :
35- row = ' {}' .format (row )
34+ row = " {}" .format (row )
3635
37- if ' \b ' in row :
38- row = row .replace (' \b ' , '' , 1 )
36+ if " \b " in row :
37+ row = row .replace (" \b " , "" , 1 )
3938 should_indent = True
4039 elif not len (row .strip ()):
4140 should_indent = False
4241
4342 rows .append (row )
4443
45- self .write ("{}\n " .format (' \n ' .join (rows )))
44+ self .write ("{}\n " .format (" \n " .join (rows )))
4645
4746 def write_dl (self , rows , ** kwargs ):
4847 """Writes a definition list into the buffer. This is how options
4948 and commands are usually formatted.
5049 :param rows: a list of two item tuples for the terms and values.
5150 """
5251 rows = list (rows )
53- self .write (' \n ' )
52+ self .write (" \n " )
5453
55- self .write (' Flag | Help\n ' )
56- self .write (' -----|-----\n ' )
54+ self .write (" Flag | Help\n " )
55+ self .write (" -----|-----\n " )
5756
5857 for row in rows :
59- self .write (' `{}` | {}\n ' .format (* row ))
60- self .write (' \n ' )
58+ self .write (" `{}` | {}\n " .format (* row ))
59+ self .write (" \n " )
6160
6261
6362class MkdocsContext (Context ):
64-
6563 @property
6664 def command_path (self ):
6765 # Not so proud of it
68- return ' watson {}' .format (self .command .name )
66+ return " watson {}" .format (self .command .name )
6967
7068 def make_formatter (self ):
7169 return MarkdownFormatter ()
@@ -84,18 +82,19 @@ def is_click_command(obj):
8482 return True
8583 return False
8684
87- content = '\n ' .join ((
88- "<!-- " ,
89- " This document has been automatically generated." ,
90- " It should NOT BE EDITED." ,
91- " To update this part of the documentation," ,
92- " please type the following from the repository root:" ,
93- " $ make docs"
94- "-->" ,
95- "" ,
96- "# Commands" ,
97- "" ,
98- ))
85+ content = "\n " .join (
86+ (
87+ "<!-- " ,
88+ " This document has been automatically generated." ,
89+ " It should NOT BE EDITED." ,
90+ " To update this part of the documentation," ,
91+ " please type the following from the repository root:" ,
92+ " $ make docs" "-->" ,
93+ "" ,
94+ "# Commands" ,
95+ "" ,
96+ )
97+ )
9998
10099 # Iterate over commands to build docs
101100 for cmd_name , cmd in inspect .getmembers (watson_cli , is_click_command ):
@@ -106,14 +105,14 @@ def is_click_command(obj):
106105
107106 # Each command is a section
108107 content += "## `{}`\n \n " .format (cmd_name )
109- content += '' .join (formatter .buffer )
108+ content += "" .join (formatter .buffer )
110109
111110 # Write the commands documentation file
112- with open (rowsput , 'w' ) as f :
111+ with open (rowsput , "w" ) as f :
113112 f .write (content )
114113
115114
116- if __name__ == ' __main__' :
115+ if __name__ == " __main__" :
117116
118- commands_md = ' docs/user-guide/commands.md'
117+ commands_md = " docs/user-guide/commands.md"
119118 main (commands_md )
0 commit comments