Added a couple of docs
This commit is contained in:
parent
7b3211bf37
commit
c7974ffe07
|
|
@ -1,5 +1,9 @@
|
||||||
# Main parser, gets config files and parses them for the context manager.
|
# Main parser, gets config files and parses them for the context manager.
|
||||||
# parse_line takes a io and outputs it all as a list of parsed elements
|
# parse_line takes a io and outputs it all as a list of parsed elements
|
||||||
|
# Usage:
|
||||||
|
# from bootstraparse.modules.parser import parse_line
|
||||||
|
# parse_line(io) -> [element, element, element]
|
||||||
|
|
||||||
# TODO: decide the parser scope
|
# TODO: decide the parser scope
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
|
|
@ -9,11 +13,10 @@ import bootstraparse.modules.syntax as syntax
|
||||||
def parse_line(io):
|
def parse_line(io):
|
||||||
"""
|
"""
|
||||||
Takes an io string and returns the parsed output.
|
Takes an io string and returns the parsed output.
|
||||||
:param io: io.StringIO
|
Parameters:
|
||||||
:params
|
io (StringIO): The io string to parse.
|
||||||
:io: io string input
|
Returns:
|
||||||
:rtype: list
|
list[syntax.SemanticType]: The parsed output.
|
||||||
:return: a list of parsed objects
|
|
||||||
"""
|
"""
|
||||||
output = []
|
output = []
|
||||||
for line in io.readlines():
|
for line in io.readlines():
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
# Module for resolving relative path problems
|
# Module for resolving relative path problems
|
||||||
# PathResolver takes a relative path in the module and outputs the absolute path,
|
# PathResolver takes a relative path in the module and outputs the absolute path,
|
||||||
# BoostraPath can deal with relative paths in the installation folder.
|
# BoostraPath can deal with relative paths in the installation folder.
|
||||||
|
# Usage:
|
||||||
|
# from bootstraparse.modules.pathresolver import PathResolver, b_path
|
||||||
|
# b_path("../relative/path/to/file") # returns absolute path to file from the bootstraparse folder
|
||||||
|
# path= PathResolver("../relative/path/to/file") # Make a PathResolver object pointing at the first path given
|
||||||
|
|
||||||
# import pathlib
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,13 @@
|
||||||
# Module for pre-parsing user files in preparation for the parser
|
# Module for pre-parsing user files in preparation for the parser
|
||||||
# the PreParser has all the methods you want and probably a lot more pls help
|
# Usage:
|
||||||
|
# from bootstraparse.modules.preparser import preparser
|
||||||
|
# pp = preparser(file, enviroment)
|
||||||
|
# pp.do_import() # imports all the modules and adds them to the file, do the same for all the files that are to be imported
|
||||||
|
# pp.do_replacements() # replaces all images and shortcuts in the file
|
||||||
|
# pp.readlines() # returns the lines of ORIGINAL file
|
||||||
|
# pp.get_all_lines() # returns the lines of the file after replacements and imports
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import regex # future: remove regex
|
import regex # future: remove regex
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,13 @@
|
||||||
# All tokens inherit a SemanticType among SemanticType, ExplicitSemanticType and EmptySemanticType
|
# All tokens inherit a SemanticType among SemanticType, ExplicitSemanticType and EmptySemanticType
|
||||||
# All tokens have a label, and __eq__ and __ne__ methods.
|
# All tokens have a label, and __eq__ and __ne__ methods.
|
||||||
# Note: there is an UnimplementedToken
|
# Note: there is an UnimplementedToken
|
||||||
|
# Usage:
|
||||||
|
# from bootstraparse.modules.syntax import line
|
||||||
|
# line.parse_line('string') # returns a List of tokens
|
||||||
|
# line_to_replace.parse_line('string') # returns a List of tokens parsed for replacements
|
||||||
|
# imports.parse_line('string', True) # returns a List of tokens parsed for imports # FUTURE: Not implemented yet
|
||||||
|
# any_token.create_diagram("filename") # Debugging
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from itertools import zip_longest
|
from itertools import zip_longest
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,17 @@
|
||||||
|
###############################################################################
|
||||||
|
# List of tools for testing
|
||||||
|
###############################################################################
|
||||||
|
# Usage:
|
||||||
|
# from bootstraparse.modules.tools import __GLk, __GL, find_*_in_file
|
||||||
|
# __GLk(n) # Returns a file link n traceback objects back
|
||||||
|
# __GL() # Returns a line number at current position
|
||||||
|
# find_*_in_file(file) # Try to find (class, function or variable) in file and return it's line number
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# List of tools for testing
|
|
||||||
###############################################################################
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Paths
|
# Paths
|
||||||
########################################
|
########################################
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue