##// END OF EJS Templates
Added option to center output and remove title.
Jonathan Frederic -
Show More
@@ -74,6 +74,15 b' class SphinxTransformer(ActivatableTransformer):'
74 "notebook" (similar to the notebook)
74 "notebook" (similar to the notebook)
75 """)
75 """)
76
76
77 center_output = Bool(False, config=True, help="""
78 Optional attempt to center all output. If this is false, no additional
79 formatting is applied.
80 """))
81
82 use_headers = Bool(True, config=True, help="""
83 Whether not a header should be added to the document.
84 """))
85
77 def __call__(self, nb, other):
86 def __call__(self, nb, other):
78 """
87 """
79 Entry
88 Entry
@@ -111,6 +120,10 b' class SphinxTransformer(ActivatableTransformer):'
111 # Prompt the user for the document style.
120 # Prompt the user for the document style.
112 other["sphinx"]["chapterstyle"] = self._prompt_chapter_title_style()
121 other["sphinx"]["chapterstyle"] = self._prompt_chapter_title_style()
113 other["sphinx"]["outputstyle"] = self._prompt_output_style()
122 other["sphinx"]["outputstyle"] = self._prompt_output_style()
123
124 # Small options
125 other["sphinx"]["centeroutput"] = self._prompt_boolean("Do you want to center the output? (false)", False)
126 other["sphinx"]["header"] = self._prompt_boolean("Should a Sphinx document header be used? (true)", True)
114 else:
127 else:
115
128
116 # Try to use the traitlets.
129 # Try to use the traitlets.
@@ -118,13 +131,17 b' class SphinxTransformer(ActivatableTransformer):'
118 nb.metadata._draft["version"] = self.version
131 nb.metadata._draft["version"] = self.version
119 nb.metadata._draft["release"] = self.release
132 nb.metadata._draft["release"] = self.release
120
133
134 # Use todays date if none is provided.
121 if len(self.publish_date.strip()) == 0:
135 if len(self.publish_date.strip()) == 0:
122 nb.metadata._draft["date"] = date.today().strftime("%B %-d, %Y")
136 nb.metadata._draft["date"] = date.today().strftime("%B %-d, %Y")
123 else:
137 else:
124 nb.metadata._draft["date"] = self.publish_date
138 nb.metadata._draft["date"] = self.publish_date
125
139
140 # Sphinx traitlets.
126 other["sphinx"]["chapterstyle"] = self.chapter_style
141 other["sphinx"]["chapterstyle"] = self.chapter_style
127 other["sphinx"]["outputstyle"] = self.output_style
142 other["sphinx"]["outputstyle"] = self.output_style
143 other["sphinx"]["centeroutput"] = self.center_output
144 other["sphinx"]["header"] = self.use_headers
128
145
129 # Find and pass in the path to the Sphinx dependencies.
146 # Find and pass in the path to the Sphinx dependencies.
130 other["sphinx"]["texinputs"] = os.path.abspath(sphinx.__file__ + "/../texinputs")
147 other["sphinx"]["texinputs"] = os.path.abspath(sphinx.__file__ + "/../texinputs")
@@ -154,6 +171,21 b' class SphinxTransformer(ActivatableTransformer):'
154 user_date = default_date
171 user_date = default_date
155 return user_date
172 return user_date
156
173
174 def _prompt_boolean(self, prompt, default=False):
175 response = self._input(prompt)
176 response = response.strip().lower()
177
178 #Catch 1, true, yes as True
179 if (response == "1" or response[0] == "t" or response[0] == "y"):
180 return True
181
182 #Catch 0, false, no as False
183 elif (response == "0" or response[0] == "f" or response[0] == "n"):
184 return False
185
186 else:
187 return Default
188
157 def _prompt_output_style(self):
189 def _prompt_output_style(self):
158
190
159 # Dictionary of available output styles
191 # Dictionary of available output styles
General Comments 0
You need to be logged in to leave comments. Login now