X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=blobdiff_plain;f=CODING.md;h=7a517e91f504e431b320632d781808ac608ce431;hp=d19eb0e5273eb803f211fa5e3a44f10f80fb7576;hb=refs%2Fheads%2Fmaster;hpb=84836e34fe06ff4b8f876cd41ac494c23ae9347e diff --git a/CODING.md b/CODING.md index d19eb0e5..4f4d492f 100644 --- a/CODING.md +++ b/CODING.md @@ -3,9 +3,15 @@ [Error Logging](#error-logging) [GPL header](#gpl-header) [Git change log](#git-change-log) -[Sources](#sources) -[Software Tools](#software-tools) +[Source Code Style](#source-code-style) +[Shell Script Style](#shell-script-style) +[External Software Tools](#external-software-tools) +[Geeqie Software Tools](#geeqie-software-tools) [Documentation](#documentation) +[Documentation - C code](#c-code) +[Documentation - Script files](#script-files) +[Documentation - Markdown](#markdown) +[Doxygen](#doxygen) --- @@ -36,6 +42,22 @@ For use with the [GTKInspector](https://wiki.gnome.org/action/show/Projects/GTK/ Sample command line call: `GTK_DEBUG=interactive src/geeqie` +### DEBUG_BT() + +Prints a backtrace. +Use only for temporary debugging i.e. not in code in the repository + +### DEBUG_FD() + +Prints a dump of the FileData hash list as a ref. count followed by the full path of the item. +Use only for temporary debugging i.e. not in code in the repository + +### Log Window + +When the Log Window has focus, the F1 key executes the action specified in `Edit/Preferences/Behavior/Log Window F1 Command` with the selected text as a parameter. +If no text is selected, the entire line is passed to the command. +This feature may be used to open an editor at a file location in the text string. + --- ## GPL header @@ -77,7 +99,7 @@ If referencing a Geeqie GitHub issue, include the issue number in the summary li Use whole sentences beginning with Capital letter. For each modification use a new line. Or you can write the theme, colon and then every change on new line, begin with "- ". -See also [A Note About Git Commit Messages](http://www.tpope.net/node/106) +See also [A Note About Git Commit Messages](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) Example: @@ -95,7 +117,7 @@ Also please use your full name and a working e-mail address as author for any co --- -## Sources +## Source Code Style Indentation: tabs at 4 spaces @@ -112,38 +134,38 @@ Conditions, cycles: ```c if () - { - ; - ... - ; - } + { + ; + ... + ; + } else - { - ; - ... - ; - } + { + ; + ... + ; + } if ( && ) ; switch () - { - case 0: - ; - ; - break; - case 1: - ; break; - } + { + case 0: + ; + ; + break; + case 1: + ; break; + } for (i = 0; i <= 10; i++) - { - ; - ... - ; - } + { + ; + ... + ; + } ``` Functions: @@ -151,18 +173,18 @@ Functions: ```c gint bar(, , ) { - ; - ... - ; + ; + ... + ; - return 0; // i.e. SUCCESS; if error, you must return minus @FIXME + return 0; // i.e. SUCCESS; if error, you must return minus @FIXME } void bar2(void) { - ; - ... - ; + ; + ... + ; } ``` @@ -181,6 +203,8 @@ Headers: #ifndef _FILENAME_H ``` +Use [Names and Order of Includes](https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes) for headers include order. + Use spaces around every operator (except `.`, `->`, `++` and `--`). Unary operator `*` and `&` are missing the space from right, (and also unary `-`). @@ -191,10 +215,30 @@ Variables declarations should be followed by a blank line and should always be a Use glib types when possible (ie. gint and gchar instead of int and char). Use glib functions when possible (i.e. `g_ascii_isspace()` instead of `isspace()`). -Check if used functions are not deprecated. +Check if used functions are not deprecated. + +--- + +## Shell Script Style + +Use `/bin/sh` as the interpreter directive. +Ensure the script is POSIX compliant. +Use `printf` rather than `echo` except for plain text. +There are several versions of `mktemp`. Using the following definition helps portability (note that `template` is not optional): + +```sh +mktemp [-d] [-q] template ... +``` + +and use for example this style: + +```sh +mktemp "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX" +``` --- -## Software Tools + +## External Software Tools ### astyle @@ -216,16 +260,12 @@ align-pointer=name align-reference=name ``` -### check-compiles.sh - -This shell script is part of the Geeqie project and will compile Geeqie with various options. - ### cppcheck A lint-style program may be used, e.g. ```sh -cppcheck --language=c --library=gtk --enable=all --force -USA_SIGINFO -UZD_EXPORT -Ugettext_noop -DG_KEY_FILE_DESKTOP_GROUP --template=gcc -I. --quiet --suppressions-list= +cppcheck --language=c --library=gtk --enable=all --force -USA_SIGINFO -UZD_EXPORT -Ugettext_noop -DG_KEY_FILE_DESKTOP_GROUP --template=gcc -I .. --quiet --suppressions-list= ``` Where the suppressions file might contain: @@ -237,25 +277,19 @@ unusedFunction unmatchedSuppression ``` -### generate-man-page.sh +### markdownlint -This script is part of the Geeqie project and should be used to generate the Geeqie man page from Geeqie's command line -help output and also update the Command Line Options section of the Help files. -The programs help2man and doclifter are required - both are available as .deb packages. +Markdown documents may be validated with e.g. [markdownlint](https://github.com/markdownlint/markdownlint). ```sh -./scripts/generate-man-page.sh +mdl --style