X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=CODING.md;h=e33bcdf53dd52ddae66a2f46b29463cd1e17de92;hb=b7618ec7c525acd94cbf31ee70afbee2342e90c9;hp=9e6bec02fd3b1c096984e0ad26a2e73e3060c0eb;hpb=31197b3d4f2ee55c84a2ae5c71995e2c5dad91c8;p=geeqie.git diff --git a/CODING.md b/CODING.md index 9e6bec02..e33bcdf5 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) --- @@ -77,7 +83,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 +101,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 +118,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 +157,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) { - ; - ... - ; + ; + ... + ; } ``` @@ -194,7 +200,26 @@ Use glib functions when possible (i.e. `g_ascii_isspace()` instead of `isspace() Check if used functions are not deprecated. --- -## Software Tools + +## 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" +``` + +--- +## External Software Tools ### astyle @@ -221,7 +246,7 @@ align-reference=name 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: @@ -233,35 +258,71 @@ unusedFunction unmatchedSuppression ``` -### shellcheck +### markdownlint -Shell scripts may also be validated, e.g. +Markdown documents may be validated with e.g. [markdownlint](https://github.com/markdownlint/markdownlint). ```sh -shellcheck --enable=add-default-case,avoid-nullary-conditions,check-unassigned-uppercase,deprecate-which,quote-safe-variables +mdl --style