Skip to content

Commit bccbe48

Browse files
committed
Updated all docstrings to be compatible with PEP 257
It's nicer to be compatible with the standards. I have added one more field to the description of each function: Side effects. This feild contains the expected side effects of running a particular method. If the side effects of a method are None, it is expected that the function does not change anything in any envoronment and that running it multiple times with the same arguments will produce the same result every time. That is when Side effects is non, the method is expected to be pure.
1 parent 4fc8c56 commit bccbe48

File tree

1 file changed

+126
-23
lines changed

1 file changed

+126
-23
lines changed

tools/toolchains/__init__.py

Lines changed: 126 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,16 @@ def compile_command(self, source, object, includes):
789789

790790
@abstractmethod
791791
def parse_dependencies(self, dep_path):
792-
"""Take in a dependency file generated by the compiler and build a list of
793-
all files that the dep_path depends on.
792+
"""Parse the dependency information generated by the compiler.
793+
794+
Positional arguments:
795+
dep_path -- the path to a file generated by a previous run of the compiler
796+
797+
Return value:
798+
A list of all source files that the dependency file indicated were dependencies
799+
800+
Side effects:
801+
None
794802
"""
795803
raise NotImplemented
796804

@@ -799,7 +807,16 @@ def is_not_supported_error(self, output):
799807

800808
@abstractmethod
801809
def parse_output(self, output):
802-
"""Take in compiler output and extract sinlge line warnings and errors from it
810+
"""Take in compiler output and extract sinlge line warnings and errors from it.
811+
812+
Positional arguments:
813+
output -- a string of all the messages emitted by a run of the compiler
814+
815+
Return value:
816+
None
817+
818+
Side effects:
819+
call self.cc_info or self.notify with a description of the event generated by the compiler
803820
"""
804821
raise NotImplemented
805822

@@ -978,56 +995,142 @@ def get_config_header(self):
978995
def get_config_option(self, config_header):
979996
"""Generate the compiler option that forces the inclusion of the configuration
980997
header file.
998+
999+
Positional arguments:
1000+
config_header -- The configuration header that will be included within all source files
1001+
1002+
Return value:
1003+
A list of the command line arguments that will force the inclusion the specified header
1004+
1005+
Side effects:
1006+
None
9811007
"""
9821008
raise NotImplemented
9831009

9841010
@abstractmethod
9851011
def assemble(self, source, object, includes):
986-
"""Generate the command line that:
987-
- Assembles the given assembly *source* file.
988-
- Puts the results into the file named *object*.
989-
- Has an include search path that includes everything in *includes*
1012+
"""Generate the command line that assembles.
1013+
1014+
Positional arguments:
1015+
source -- a file path that is the file to assemble
1016+
object -- a file path that is the destination object
1017+
includes -- a list of all directories where header files may be found
1018+
1019+
Return value:
1020+
The complete command line, as a list, that would invoke the assembler
1021+
on the source file, include all the include paths, and generate
1022+
the specified object file.
1023+
1024+
Side effects:
1025+
None
1026+
1027+
Note:
1028+
This method should be decorated with @hook_tool.
9901029
"""
9911030
raise NotImplemented
9921031

9931032
@abstractmethod
9941033
def compile_c(self, source, object, includes):
995-
"""Generate the command line that:
996-
- Compiles the given C *source* file.
997-
- Puts the results into the file named *object*.
998-
- Has an include search path that includes everything in *includes*
1034+
"""Generate the command line that compiles a C source file.
1035+
1036+
Positional arguments:
1037+
source -- the C source file to compile
1038+
object -- the destination object file
1039+
includes -- a list of all the directories where header files may be found
1040+
1041+
Return value:
1042+
The complete command line, as a list, that would invoke the C compiler
1043+
on the source file, include all the include paths, and generate the
1044+
specified object file.
1045+
1046+
Side effects:
1047+
None
1048+
1049+
Note:
1050+
This method should be decorated with @hook_tool.
9991051
"""
10001052
raise NotImplemented
10011053

10021054
@abstractmethod
10031055
def compile_cpp(self, source, object, includes):
1004-
"""Generate the command line that:
1005-
- Compiles the given C++ *source* file.
1006-
- Puts the results into the file named *object*.
1007-
- Has an include search path that includes everything in *includes*
1056+
"""Generate the command line that compiles a C++ source file.
1057+
1058+
Positional arguments:
1059+
source -- the C++ source file to compile
1060+
object -- the destination object file
1061+
includes -- a list of all the directories where header files may be found
1062+
1063+
Return value:
1064+
The complete command line, as a list, that would invoke the C++ compiler
1065+
on the source file, include all the include paths, and generate the
1066+
specified object file.
1067+
1068+
Side effects:
1069+
None
1070+
1071+
Note:
1072+
This method should be decorated with @hook_tool.
10081073
"""
10091074
raise NotImplemented
10101075

10111076
@abstractmethod
10121077
def link(self, output, objects, libraries, lib_dirs, mem_map):
1013-
"""Run the link command that will:
1014-
- Emit a file named *output*
1015-
- Includes all *objects* and *libraries*
1016-
- Searches for libraries in *lib_dirs*
1017-
- Generates a memory map file in the file *mem_map*
1078+
"""Run the linker to create an executable and memory map.
1079+
1080+
Positional arguments:
1081+
output -- the file name to place the executable in
1082+
objects -- all of the object files to link
1083+
libraries -- all of the required libraries
1084+
lib_dirs -- where the required libraries are located
1085+
mem_map -- the location where the memory map file should be stored
1086+
1087+
Return value:
1088+
None
1089+
1090+
Side effect:
1091+
Runs the linker to produce the executable.
1092+
1093+
Note:
1094+
This method should be decorated with @hook_tool.
10181095
"""
10191096
raise NotImplemented
10201097

10211098
@abstractmethod
10221099
def archive(self, objects, lib_path):
1023-
"""Run the command line that creates an archive containing *objects*, and named *lib_path*
1100+
"""Run the command line that creates an archive.
1101+
1102+
Positional arguhments:
1103+
objects -- a list of all the object files that should be archived
1104+
lib_path -- the file name of the resulting library file
1105+
1106+
Return value:
1107+
None
1108+
1109+
Side effect:
1110+
Runs the archiving tool to produce the library file.
1111+
1112+
Note:
1113+
This method should be decorated with @hook_tool.
10241114
"""
10251115
raise NotImplemented
10261116

10271117
@abstractmethod
10281118
def binary(self, resources, elf, bin):
1029-
"""Run the command line that will Extract a binary named *bin* from an
1030-
elf file named *elf*.
1119+
"""Run the command line that will Extract a simplified binary file.
1120+
1121+
Positional arguments:
1122+
resources -- A resources object (Is not used in any of the toolchains)
1123+
elf -- the executable file that is to be converted
1124+
bin -- the file name of the to be created simplified binary file
1125+
1126+
Return value:
1127+
None
1128+
1129+
Side effect:
1130+
Runs the elf2bin tool to produce the simplified binary file.
1131+
1132+
Note:
1133+
This method should be decorated with @hook_tool.
10311134
"""
10321135
raise NotImplemented
10331136

0 commit comments

Comments
 (0)