File tree Expand file tree Collapse file tree 5 files changed +73
-1
lines changed
doc/tutorials/introduction/documenting_opencv Expand file tree Collapse file tree 5 files changed +73
-1
lines changed Original file line number Diff line number Diff line change
1
+ # - Find Pylint
2
+ # Find the Pylint executable and extract the version number
3
+ #
4
+ # OUTPUT Variables
5
+ #
6
+ # PYLINT_FOUND
7
+ # True if the pylint package was found
8
+ # PYLINT_EXECUTABLE
9
+ # The pylint executable location
10
+ # PYLINT_VERSION
11
+ # A string denoting the version of pylint that has been found
12
+
13
+ find_program (PYLINT_EXECUTABLE pylint PATHS /usr/bin )
14
+
15
+ if (PYLINT_EXECUTABLE )
16
+ execute_process (COMMAND ${PYLINT_EXECUTABLE} --version OUTPUT_VARIABLE PYLINT_VERSION_RAW ERROR_QUIET )
17
+ if (PYLINT_VERSION_RAW )
18
+ string (REGEX REPLACE "^pylint ([0-9]+.[0-9]+.[0-9]+),.*" "\\ 1" PYLINT_VERSION ${PYLINT_VERSION_RAW} )
19
+ else ()
20
+ set (PYLINT_VERSION "unknown" )
21
+ endif ()
22
+ endif ()
23
+
24
+ include (FindPackageHandleStandardArgs )
25
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS (Pylint DEFAULT_MSG PYLINT_EXECUTABLE )
26
+
27
+ mark_as_advanced (PYLINT_EXECUTABLE PYLINT_VERSION )
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ Generate documentation {#tutorial_documentation_generate}
43
43
make doxygen
44
44
@endcode
45
45
- Open <i >doc/doxygen/html/index.html</i > file in your favorite browser
46
+ - Test your python code:
47
+ @code {.sh}
48
+ make run_pylint_on_tutorials
49
+ @endcode
46
50
47
51
Quick start {#tutorial_documentation_quick_start}
48
52
===========
@@ -600,7 +604,8 @@ Document the function {#tutorial_documentation_steps_fun}
600
604
6 . _ Optional_ : describe return value of the function using the _ returns_ command.
601
605
7 . _ Optional_ : add "See also" section with links to similar functions or classes
602
606
8 . _ Optional_ : add bibliographic reference if any.
603
- 9 . Generate doxygen documentation and verify results.
607
+ 9 . Test your code. (Python: "make run_pylint_on_tutorials")
608
+ 10 . Generate doxygen documentation and verify results.
604
609
605
610
Write the tutorial {#tutorial_documentation_steps_tutorial}
606
611
------------------
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
12
12
13
13
add_subdirectory (cpp )
14
14
add_subdirectory (java/tutorial_code )
15
+ add_subdirectory (python/tutorial_code )
15
16
add_subdirectory (dnn )
16
17
add_subdirectory (gpu )
17
18
add_subdirectory (tapi )
Original file line number Diff line number Diff line change
1
+ # ----------------------------------------------------------------------------
2
+ # CMake file to run pylint on the tutorial python files.
3
+ #
4
+ # ----------------------------------------------------------------------------
5
+ include (${CMAKE_SOURCE_DIR} /cmake/FindPylint.cmake )
6
+
7
+ project (run_pylint_on_tutorials )
8
+
9
+ if (PYLINT_FOUND )
10
+ message (STATUS "pylint version: ${PYLINT_VERSION} " )
11
+ set (curdir "${CMAKE_CURRENT_SOURCE_DIR} " )
12
+ file (GLOB_RECURSE PYTHON_SCRIPTS ${curdir} /*.py )
13
+ add_custom_target ("${PROJECT_NAME} " )
14
+
15
+ foreach (SCRIPT ${PYTHON_SCRIPTS} )
16
+ get_filename_component (SCRIPT_NAME ${SCRIPT} NAME_WE )
17
+ add_custom_command (TARGET "${PROJECT_NAME} "
18
+ COMMAND ${PYLINT_EXECUTABLE} ${SCRIPT}
19
+ --rcfile=${curdir}/pylintrc
20
+ COMMENT "Running pylint on : ${SCRIPT_NAME} .py"
21
+ )
22
+ endforeach ()
23
+ endif ()
Original file line number Diff line number Diff line change
1
+ [MESSAGES CONTROL]
2
+
3
+ # Disable all to choose the Tests one by one
4
+ disable =all
5
+
6
+ # Tests
7
+ enable =bad-indentation, # Used when an unexpected number of indentation’s tabulations or spaces has been found.
8
+ mixed-indentation, # Used when there are some mixed tabs and spaces in a module.
9
+ unnecessary-semicolon, # Used when a statement is ended by a semi-colon (”;”), which isn’t necessary.
10
+ unused-variable # Used when a variable is defined but not used. (Use _var to ignore var).
11
+
12
+
13
+ [REPORTS]
14
+
15
+ # Activate the evaluation score.
16
+ score =no
You can’t perform that action at this time.
0 commit comments