@@ -91,7 +91,9 @@ class CogGeneratedError(CogError):
91
91
92
92
class CogUserException (CogError ):
93
93
"""An exception caught when running a user's cog generator.
94
+
94
95
The argument is the traceback message to print.
96
+
95
97
"""
96
98
97
99
pass
@@ -202,9 +204,11 @@ def outl(self, sOut="", **kw):
202
204
203
205
def error (self , msg = "Error raised by cog generator." ):
204
206
"""The cog.error function.
207
+
205
208
Instead of raising standard python errors, cog generators can use
206
209
this function. It will display the error without a scary Python
207
210
traceback.
211
+
208
212
"""
209
213
raise CogGeneratedError (msg )
210
214
@@ -363,8 +367,10 @@ def isEndOutputLine(self, s):
363
367
return self .options .sEndOutput in s
364
368
365
369
def createCogModule (self ):
366
- """Make a cog "module" object so that imported Python modules
367
- can say "import cog" and get our state.
370
+ """Make a cog "module" object.
371
+
372
+ Imported Python modules can use "import cog" to get our state.
373
+
368
374
"""
369
375
self .cogmodule = types .SimpleNamespace ()
370
376
self .cogmodule .path = []
@@ -390,9 +396,10 @@ def openInputFile(self, fname):
390
396
391
397
def processFile (self , fIn , fOut , fname = None , globals = None ):
392
398
"""Process an input file object to an output file object.
393
- fIn and fOut can be file objects, or file names.
394
- """
395
399
400
+ `fIn` and `fOut` can be file objects, or file names.
401
+
402
+ """
396
403
sFileIn = fname or ""
397
404
sFileOut = fname or ""
398
405
fInToClose = fOutToClose = None
@@ -589,7 +596,9 @@ def processFile(self, fIn, fOut, fname=None, globals=None):
589
596
590
597
def suffixLines (self , text ):
591
598
"""Add suffixes to the lines in text, if our options desire it.
592
- text is many lines, as a single string.
599
+
600
+ `text` is many lines, as a single string.
601
+
593
602
"""
594
603
if self .options .sSuffix :
595
604
# Find all non-blank lines, and add the suffix to the end.
@@ -598,8 +607,10 @@ def suffixLines(self, text):
598
607
return text
599
608
600
609
def processString (self , sInput , fname = None ):
601
- """Process sInput as the text to cog.
610
+ """Process `sInput` as the text to cog.
611
+
602
612
Return the cogged output as a string.
613
+
603
614
"""
604
615
fOld = io .StringIO (sInput )
605
616
fNew = io .StringIO ()
@@ -737,8 +748,9 @@ def processArguments(self, args):
737
748
738
749
def callableMain (self , argv ):
739
750
"""All of command-line cog, but in a callable form.
740
- This is used by main.
741
- argv is the equivalent of sys.argv.
751
+
752
+ This is used by main. `argv` is the equivalent of sys.argv.
753
+
742
754
"""
743
755
argv = argv [1 :]
744
756
0 commit comments