1. General rules
2. FreeCAD FEM specific requirements
3. Macro info requirements
1. General rules
The general rule is to follow PEP8  and use flake8  (or anything that allows PEP8 checks) to enforce it. Use common sense if PEP8 doesn't apply
1.1 Use spaces only with 4 spaces for indent
1.2 Naming policy : ClassNames, variable_names_without_capitals and CONSTANTS_USE_CAPITALS, functions_without_capitals
1.3 Function expected to return a value should indicate what is expected, so is_mesh_valid is a good name, but check_mesh is not a good name
1.4 No trailing spaces or empty lines with white space characters allowed. If you refactor code please clean it!
1.5 It's OK to use a short variable name like x or z for a local variable used in one place, but if the variable is used in many places it should have a meaningful name.
1.6 Icon names should use fem- prefix, only small letters and dashes for separation. like fem-add-part or fem-inp-editor. The only exception is preferences-fem.svg which is used for FEM preferences.
1.7 print strings shall use brackets for future compatibility with python3. In general the code should be written in python3 compatible manner unless it doesn't work with python2
1.8 One import per line, no * imports allowed as it makes harder to validate code.
2. FreeCAD specific requirements
2.1 All files should have a licence header (FIXME - add example)
2.2 Line length is not enforced (should we enforce it?) - please use common sense
2.3 All python functions should have doxygen documentation included 
2.4 File name should reflect class name, so FemTools.py contains FemTools class
2.5 Class names and file names that are not supposed to be used for scripting should start with underscore like _MyInternalClass
2.6 FEM GUI commands should inherit from FemCommands class. See see/Mod/Fem/_Command* files as examples.
3. Info that should be included in all macros. Requested by macro manager developer microelly2
Code: Select all
__Comment__ = 'Imports and scales an Airfoil in the form of a Draft Wire (DWire) or Basic Spline (BSpline)' __Web__ = 'http://forum.freecadweb.org/viewtopic.php?f=22&t=5554' __Wiki__ = "http://www.freecadweb.org/wiki/index.php?title=Macro_Airfoil_Import_%26_Scale' __Icon__ = '/usr/lib/freecad/Mod/plugins/icons/airfoil.png' __Help__ = 'Start the macro and follow the instructions' __Author__ = 'quick61' __Version__ = '2.1' __Status__ = 'stable' __Requires__ = 'freecad 0.14.3706' __Communication__ = 'your email adress or yourgit or something else'
 https://github.com/FreeCAD/FreeCAD/blob ... ls.py#L100
Footnote: coding rules are to some extent matter of personal preference and as such are always open to discussion. If you don't like those above please provide a good example why they need to be changed, so we can improve them!