Skip to content

Commit

Permalink
Change expression help from free form html files to structured json
Browse files Browse the repository at this point in the history
A new script then parses these json help files into the html help
contents, in a standardised manner. Previously, the function help
was a bunch of different formats and structures.

Now, a custom stylesheet can be applied (and later tweaked!) to
format these help. Eg, this commit colors variables and function
names in the syntax section for greater readability.
  • Loading branch information
nyalldawson committed Sep 2, 2015
1 parent 524716f commit 709c143
Show file tree
Hide file tree
Showing 277 changed files with 1,087 additions and 1,860 deletions.
12 changes: 0 additions & 12 deletions resources/function_help/$area

This file was deleted.

13 changes: 0 additions & 13 deletions resources/function_help/$atlasfeature

This file was deleted.

14 changes: 0 additions & 14 deletions resources/function_help/$atlasfeatureid

This file was deleted.

15 changes: 0 additions & 15 deletions resources/function_help/$atlasgeometry

This file was deleted.

19 changes: 15 additions & 4 deletions resources/function_help/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FILE(GLOB HELP_FILES *)

LIST(REMOVE_ITEM HELP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt)
FILE(GLOB HELP_FILES text/*)
FILE(GLOB JSON_HELP_FILES json/*)

SET(HELP_OUTPUT "${CMAKE_SOURCE_DIR}/src/core/qgsexpression_texts.cpp")

Expand All @@ -10,12 +9,24 @@ LIST(SORT HELP_FILES)

FOREACH(HELP_FILE ${HELP_FILES})
STRING(REGEX REPLACE "^.*/([^/]+)$" "\\1" FN ${HELP_FILE})

FILE(READ ${HELP_FILE} HELP)
STRING(REPLACE "\\" "\" HELP "${HELP}")
STRING(REPLACE "\"" "\\\"" HELP "${HELP}")
STRING(REPLACE "\n" "\\n\"\n\"" HELP "${HELP}")
FILE(APPEND ${HELP_OUTPUT} "\n gFunctionHelpTexts.insert( \"${FN}\", QCoreApplication::translate( \"function_help\", \"${HELP}\") );")
ENDFOREACH(HELP_FILE ${HELP_FILES})

FOREACH(HELP_FILE ${JSON_HELP_FILES})
STRING(REGEX REPLACE "^.*/([^/]+)$" "\\1" FN ${HELP_FILE})
STRING(REPLACE "\$" "\\$" HELP_FILE "${HELP_FILE}")
EXEC_PROGRAM(${PYTHON_EXECUTABLE} ARGS "${CMAKE_CURRENT_SOURCE_DIR}/../process_function_template.py" "${HELP_FILE}" OUTPUT_VARIABLE HELP RETURN_VALUE RET )
IF(NOT "${RET}" STREQUAL "0")
MESSAGE(FATAL_ERROR "parsing function help ${HELP_FILE} failed: ${HELP}")
ENDIF()
STRING(REPLACE "\\" "\" HELP "${HELP}")
STRING(REPLACE "\"" "\\\"" HELP "${HELP}")
STRING(REPLACE "\n" "\\n\"\n\"" HELP "${HELP}")
FILE(APPEND ${HELP_OUTPUT} "\n gFunctionHelpTexts.insert( \"${FN}\", QCoreApplication::translate( \"function_help\", \"${HELP}\") );")
ENDFOREACH(HELP_FILE ${HELP_FILES})

FILE(APPEND ${HELP_OUTPUT} "\n}\n")
12 changes: 0 additions & 12 deletions resources/function_help/abs

This file was deleted.

12 changes: 0 additions & 12 deletions resources/function_help/acos

This file was deleted.

32 changes: 0 additions & 32 deletions resources/function_help/age

This file was deleted.

12 changes: 0 additions & 12 deletions resources/function_help/asin

This file was deleted.

12 changes: 0 additions & 12 deletions resources/function_help/atan

This file was deleted.

15 changes: 0 additions & 15 deletions resources/function_help/atan2

This file was deleted.

13 changes: 0 additions & 13 deletions resources/function_help/attribute

This file was deleted.

12 changes: 0 additions & 12 deletions resources/function_help/bounds

This file was deleted.

12 changes: 0 additions & 12 deletions resources/function_help/bounds_height

This file was deleted.

12 changes: 0 additions & 12 deletions resources/function_help/bounds_width

This file was deleted.

13 changes: 0 additions & 13 deletions resources/function_help/buffer

This file was deleted.

14 changes: 0 additions & 14 deletions resources/function_help/ceil

This file was deleted.

12 changes: 0 additions & 12 deletions resources/function_help/centroid