Functions | |
| changeMarkdown (code) | |
| convertDoxygenLatexToMarkdown (text) | |
| Replace formula tags used by doxygen to the ones used in notebooks. | |
| cppComments (text) | |
| Converts comments delimited by // and on a new line into a markdown cell. | |
| cppFunction (text) | |
| Extracts main function for the function enclosure by means of regular expression. | |
| declareIncludes (code) | |
| declareNamespace (code) | |
| disableDrawProgressBar (code) | |
| findBracedBlock (text, startpos, openingBraceChar) | |
| Scan the string in <text>, starting at <startpos>. | |
| findStuffBeforeFunc (text, searchStart, searchEnd) | |
| findTimeout () | |
| fixes (code) | |
| getLibMathMore (code) | |
| isCpp () | |
| Return True if extension is a C++ file. | |
| mainfunction (text) | |
| Main function. | |
| measureIndentation (text) | |
| Measure the indentation width. | |
| processmain (text) | |
| Evaluates whether the main function returns a TCanvas or requires input. | |
| pythonComments (text) | |
| Converts comments delimited by # or ## and on a new line into a markdown cell. | |
| pythonMainFunction (text) | |
| readHeaderCpp (text) | |
| Extract author and description from header, eliminate header from text. | |
| readHeaderPython (text) | |
| Extract author and description from header, eliminate header from text. | |
| removePaletteEditor (code) | |
| roofitRemoveSpacesComments (code) | |
| rs401dGetFiles (code) | |
| runEventExe (code) | |
| split (text) | |
| Splits the text string into main, helpers, and rest. | |
| tree4GetFiles (code) | |
| unindenter (string, spaces=3) | |
| Returns string with each line unindented by 3 spaces. | |
Variables | |
| author | |
| date = datetime.now().strftime("%A, %B %d, %Y at %I:%M %p") | |
| description | |
| extension | |
| isJsroot | |
| isNotebook | |
| needsHeaderFile | |
| nodraw | |
| outdir = str(sys.argv[2]) | |
| str | outname = tutFileName + ".ipynb" |
| str | outnameconverted = tutFileName + ".nbconvert.ipynb" |
| outPathName = os.path.join(outdir, outname) | |
| ret = mainfunction(text) | |
| starttime = time.time() | |
| text = fin.read() | |
| tutFileName = os.path.basename(tutPathName) | |
| str | tutName = "tutorial" |
| tutPath = os.path.dirname(tutPathName) | |
| tutPathName = str(sys.argv[1]) | |
| str | tutRelativePath = "$ROOTSYS/tutorials/%s/" % tutPath.split("/")[-1] |
| str | tutTitle = tutName |
| verbose | |
| converttonotebook.changeMarkdown | ( | code | ) |
Definition at line 676 of file converttonotebook.py.
| converttonotebook.convertDoxygenLatexToMarkdown | ( | text | ) |
Replace formula tags used by doxygen to the ones used in notebooks.
Definition at line 227 of file converttonotebook.py.
| converttonotebook.cppComments | ( | text | ) |
Converts comments delimited by // and on a new line into a markdown cell.
Skips comments inside blocks and braces, though, since these would otherwise be ripped apart. For C++ files only.
cppComments('''// This is a ... // multiline comment ... void function(){}''') '# <markdowncell>\n# This is a\n# multiline comment\n# <codecell>\nvoid function(){}\n' cppComments('''void function(){ ... int variable = 5 // Comment not in cell ... // Comment also not in cell ... }''') 'void function(){\n int variable = 5 // Comment not in cell\n // Comment also not in cell\n}\n'
Definition at line 339 of file converttonotebook.py.
| converttonotebook.cppFunction | ( | text | ) |
Extracts main function for the function enclosure by means of regular expression.
cppFunction('''void mainfunction(arguments = values){ ... content of function ... which spans ... several lines ... }''') '\n content of function\n which spans\n several lines\n' cppFunction('''void mainfunction(arguments = values) ... { ... content of function ... which spans ... several lines ... }''') '\n content of function\n which spans\n several lines\n' cppFunction('''void mainfunction(arguments = values ... morearguments = morevalues) ... { ... content of function ... which spans ... several lines ... }''') '\n content of function\n which spans\n several lines\n'
Definition at line 305 of file converttonotebook.py.
| converttonotebook.declareIncludes | ( | code | ) |
Definition at line 647 of file converttonotebook.py.
| converttonotebook.declareNamespace | ( | code | ) |
Definition at line 628 of file converttonotebook.py.
| converttonotebook.disableDrawProgressBar | ( | code | ) |
Definition at line 660 of file converttonotebook.py.
| converttonotebook.findBracedBlock | ( | text, | |
| startpos, | |||
| openingBraceChar ) |
Scan the string in <text>, starting at <startpos>.
Return index of opening and matching closing brace if present. The brace to search for is passed in <openingBraceChar>, e.g. '(', '{', '['.
Definition at line 390 of file converttonotebook.py.
| converttonotebook.findStuffBeforeFunc | ( | text, | |
| searchStart, | |||
| searchEnd ) |
Definition at line 425 of file converttonotebook.py.
| converttonotebook.findTimeout | ( | ) |
Definition at line 690 of file converttonotebook.py.
| converttonotebook.fixes | ( | code | ) |
Definition at line 663 of file converttonotebook.py.
| converttonotebook.getLibMathMore | ( | code | ) |
Definition at line 609 of file converttonotebook.py.
| converttonotebook.isCpp | ( | ) |
Return True if extension is a C++ file.
Definition at line 683 of file converttonotebook.py.
| converttonotebook.mainfunction | ( | text | ) |
Main function.
Calls all other functions, depending on whether the macro input is in python or c++. It adds the header information. Also, it adds a cell that draws all canvases. The working text is then converted to a version 3 jupyter notebook, subsequently updated to a version 4. Then, metadata associated with the language the macro is written in is attatched to he notebook. Finally the notebook is executed and output as a Jupyter notebook.
Definition at line 710 of file converttonotebook.py.
| converttonotebook.measureIndentation | ( | text | ) |
Measure the indentation width.
Definition at line 96 of file converttonotebook.py.
| converttonotebook.processmain | ( | text | ) |
Evaluates whether the main function returns a TCanvas or requires input.
If it does then the keepfunction flag is True, meaning the function wont be extracted by cppFunction. If the initial condition is true then an extra cell is added before at the end that calls the main function is returned, and added later.
processmain('''void function(){ ... content of function ... spanning several ... lines ... }''') ('void function(){\n content of function\n spanning several\n lines\n}', '') processmain('''void function(arguments = values){ ... content of function ... spanning several ... lines ... }''') ('void function(arguments = values){\n content of function\n spanning several\n lines\n}', '# <markdowncell> \n Arguments are defined. \n# <codecell>\narguments = values;\n# <codecell>\n') processmain('''void function(argument1 = value1, //comment 1 ... argument2 = value2 /*comment 2*/ , ... argument3 = value3, ... argument4 = value4) ... { ... content of function ... spanning several ... lines ... }''') ('void function(argument1 = value1, //comment 1\n argument2 = value2 /*comment 2*/ ,\n argument3 = value3, \n argument4 = value4)\n{\n content of function\n spanning several\n lines\n}', '# <markdowncell> \n Arguments are defined. \n# <codecell>\nargument1 = value1;\nargument2 = value2;\nargument3 = value3;\nargument4 = value4;\n# <codecell>\n') processmain('''TCanvas function(){ ... content of function ... spanning several ... lines ... return c1 ... }''') ('TCanvas function(){\n content of function\n spanning several \n lines\n return c1\n}', '')
Definition at line 543 of file converttonotebook.py.
| converttonotebook.pythonComments | ( | text | ) |
Converts comments delimited by # or ## and on a new line into a markdown cell.
For python files only
pythonComments('''## This is a ... ## multiline comment ... def function()''') '# <markdowncell>\n## This is a\n## multiline comment\n# <codecell>\ndef function()\n' pythonComments('''def function(): ... variable = 5 # Comment not in cell ... # Comment also not in cell''') 'def function():\n variable = 5 # Comment not in cell\n # Comment also not in cell\n'
Definition at line 173 of file converttonotebook.py.
| converttonotebook.pythonMainFunction | ( | text | ) |
Definition at line 203 of file converttonotebook.py.
| converttonotebook.readHeaderCpp | ( | text | ) |
Extract author and description from header, eliminate header from text.
Also returns notebook boolean, which is True if the string \notebook is present in the header Also determine options (-js, -nodraw, -header) passed in \notebook command, and return their booleans
readHeaderCpp('''/// \file ... /// \ingroup tutorials ... /// \\notebook ... /// This is the description of the tutorial ... /// ... /// \macro_image ... /// \macro_code ... /// ... /// \\author John Brown ... void tutorialfuncion(){}''') ('void tutorialfuncion(){}\n', '# This is the description of the tutorial\n# \n# \n', 'John Brown', True, False, False, False) readHeaderCpp('''/// \file ... /// \ingroup tutorials ... /// \\notebook -js ... /// This is the description of the tutorial ... /// ... /// \macro_image ... /// \macro_code ... /// ... /// \\author John Brown ... void tutorialfuncion(){}''') ('void tutorialfuncion(){}\n', '# This is the description of the tutorial\n# \n# \n', 'John Brown', True, True, False, False) readHeaderCpp('''/// \file ... /// \ingroup tutorials ... /// \\notebook -nodraw ... /// This is the description of the tutorial ... /// ... /// \macro_image ... /// \macro_code ... /// ... /// \\author John Brown ... void tutorialfuncion(){}''') ('void tutorialfuncion(){}\n', '# This is the description of the tutorial\n# \n# \n', 'John Brown', True, False, True, False)
Definition at line 234 of file converttonotebook.py.
| converttonotebook.readHeaderPython | ( | text | ) |
Extract author and description from header, eliminate header from text.
Also returns notebook boolean, which is True if the string \notebook is present in the header Also determine options (-js, -nodraw, -header) passed in \notebook command, and return their booleans
readHeaderPython('''## \file ... ## \ingroup tutorials ... ## \\notebook ... ## This is the description of the tutorial ... ## ... ## \macro_image ... ## \macro_code ... ## ... ## \\author John Brown ... def tutorialfuncion()''') ('def tutorialfuncion()\n', 'This is the description of the tutorial\n\n\n', 'John Brown', True, False, False, False) readHeaderPython('''## \file ... ## \ingroup tutorials ... ## \\notebook -js ... ## This is the description of the tutorial ... ## ... ## \macro_image ... ## \macro_code ... ## ... ## \\author John Brown ... def tutorialfuncion()''') ('def tutorialfuncion()\n', 'This is the description of the tutorial\n\n\n', 'John Brown', True, True, False, False) readHeaderPython('''## \file ... ## \ingroup tutorials ... ## \\notebook -nodraw ... ## This is the description of the tutorial ... ## ... ## \macro_image ... ## \macro_code ... ## ... ## \\author John Brown ... def tutorialfuncion()''') ('def tutorialfuncion()\n', 'This is the description of the tutorial\n\n\n', 'John Brown', True, False, True, False)
Definition at line 102 of file converttonotebook.py.
| converttonotebook.removePaletteEditor | ( | code | ) |
Definition at line 597 of file converttonotebook.py.
| converttonotebook.roofitRemoveSpacesComments | ( | code | ) |
Definition at line 615 of file converttonotebook.py.
| converttonotebook.rs401dGetFiles | ( | code | ) |
Definition at line 640 of file converttonotebook.py.
| converttonotebook.runEventExe | ( | code | ) |
Definition at line 603 of file converttonotebook.py.
| converttonotebook.split | ( | text | ) |
Splits the text string into main, helpers, and rest.
main is the main function, i.e. the function with the same name as the macro file. Helpers is a list of strings, each a helper function, i.e. any other function that is not the main function. Finally, rest is a string containing any top-level code/declarations outside of any function. Comments above a function will be converted to a markdown cell in notebooks. Intended for C++ files only.
split('''void tutorial(){ ... content of tutorial ... }''') ('void tutorial(){\n content of tutorial\n}', [], '') split('''void tutorial(){ ... content of tutorial ... } ... void helper(arguments = values){ ... helper function ... content spans lines ... }''') ('void tutorial(){\n content of tutorial\n}', ['\n# <markdowncell>\n A helper function is created: \n# <codecell>\n%cpp -d\nvoid helper(arguments = values){\n helper function\n content spans lines\n}'], '') split('''#include <header.h> ... using namespace NAMESPACE ... void tutorial(){ ... content of tutorial ... } ... void helper(arguments = values){ ... helper function ... content spans lines ... }''') ('void tutorial(){\n content of tutorial\n}', ['\n# <markdowncell>\n A helper function is created: \n# <codecell>\n%cpp -d\nvoid helper(arguments = values){\n helper function\n content spans lines\n}'], '#include <header.h>\nusing namespace NAMESPACE') split('''void tutorial(){ ... content of tutorial ... } ... // This is a multiline ... // description of the ... // helper function ... void helper(arguments = values){ ... helper function ... content spans lines ... }''') ('void tutorial(){\n content of tutorial\n}', ['\n# <markdowncell>\n This is a multiline\n description of the\n helper function\n \n# <codecell>\n%cpp -d\nvoid helper(arguments = values){\n helper function\n content spans lines\n}'], '')
Definition at line 435 of file converttonotebook.py.
| converttonotebook.tree4GetFiles | ( | code | ) |
Definition at line 653 of file converttonotebook.py.
| converttonotebook.unindenter | ( | string, | |
| spaces = 3 ) |
Returns string with each line unindented by 3 spaces.
If line isn't indented, it stays the same.
unindenter(" foobar") 'foobar\n' unindenter("foobar") 'foobar\n' unindenter('''foobar ... foobar ... foobar''') 'foobar\nfoobar\nfoobar\n'
Definition at line 74 of file converttonotebook.py.
| converttonotebook.author |
Definition at line 893 of file converttonotebook.py.
| converttonotebook.date = datetime.now().strftime("%A, %B %d, %Y at %I:%M %p") |
Definition at line 877 of file converttonotebook.py.
| converttonotebook.description |
Definition at line 893 of file converttonotebook.py.
| converttonotebook.extension |
Definition at line 863 of file converttonotebook.py.
| converttonotebook.isJsroot |
Definition at line 893 of file converttonotebook.py.
| converttonotebook.isNotebook |
Definition at line 893 of file converttonotebook.py.
| converttonotebook.needsHeaderFile |
Definition at line 893 of file converttonotebook.py.
| converttonotebook.nodraw |
Definition at line 893 of file converttonotebook.py.
| converttonotebook.outdir = str(sys.argv[2]) |
Definition at line 871 of file converttonotebook.py.
| str converttonotebook.outname = tutFileName + ".ipynb" |
Definition at line 866 of file converttonotebook.py.
| str converttonotebook.outnameconverted = tutFileName + ".nbconvert.ipynb" |
Definition at line 867 of file converttonotebook.py.
Definition at line 875 of file converttonotebook.py.
| converttonotebook.ret = mainfunction(text) |
Definition at line 900 of file converttonotebook.py.
| converttonotebook.starttime = time.time() |
Definition at line 898 of file converttonotebook.py.
| converttonotebook.text = fin.read() |
Definition at line 889 of file converttonotebook.py.
| converttonotebook.tutFileName = os.path.basename(tutPathName) |
Definition at line 862 of file converttonotebook.py.
| converttonotebook.tutName = "tutorial" |
Definition at line 849 of file converttonotebook.py.
| converttonotebook.tutPath = os.path.dirname(tutPathName) |
Definition at line 859 of file converttonotebook.py.
| converttonotebook.tutPathName = str(sys.argv[1]) |
Definition at line 858 of file converttonotebook.py.
| str converttonotebook.tutRelativePath = "$ROOTSYS/tutorials/%s/" % tutPath.split("/")[-1] |
Definition at line 861 of file converttonotebook.py.
| str converttonotebook.tutTitle = tutName |
Definition at line 865 of file converttonotebook.py.
| converttonotebook.verbose |
Definition at line 850 of file converttonotebook.py.