Skip to content
Permalink
Browse files

SIP 4.19.7+ allows to document template based classes

  • Loading branch information
3nids committed Jan 16, 2018
1 parent 8c74c5b commit 5327978ecf0626d0c808019332636578a633ec29
Showing with 48 additions and 22 deletions.
  1. +2 −2 python/core/qgsrange.sip
  2. +27 −17 scripts/sipify.pl
  3. +11 −1 scripts/sipify_all.sh
  4. +6 −0 src/core/qgis_sip.h
  5. +2 −2 src/core/qgsrange.h
@@ -246,9 +246,9 @@ Returns true if this range overlaps another range.
};


typedef QgsTemporalRange< QDate > QgsDateRange;
typedef QgsTemporalRange< QDate > QgsDateRange ;

typedef QgsTemporalRange< QDateTime > QgsDateTimeRange;
typedef QgsTemporalRange< QDateTime > QgsDateTimeRange ;

/************************************************************************
* This file has been generated automatically from *
@@ -23,7 +23,8 @@

# read arguments
my $debug = 0;
die("usage: $0 [-debug] headerfile\n") unless GetOptions ("debug" => \$debug) && @ARGV == 1;
my $SUPPORT_TEMPLATE_DOCSTRING = 0;
die("usage: $0 [-debug] [-template-doc] headerfile\n") unless GetOptions ("debug" => \$debug, "template-doc" => \$SUPPORT_TEMPLATE_DOCSTRING) && @ARGV == 1;
my $headerfile = $ARGV[0];

# read file
@@ -51,6 +52,7 @@
my $COMMENT_PARAM_LIST = 0;
my $COMMENT_LAST_LINE_NOTE_WARNING = 0;
my $COMMENT_CODE_SNIPPET = 0;
my $COMMENT_TEMPLATE_DOCSTRING = 0;
my $GLOB_IFDEF_NESTING_IDX = 0;
my @GLOB_BRACKET_NESTING_IDX = (0);
my $PRIVATE_SECTION_LINE = '';
@@ -370,6 +372,7 @@ sub fix_annotations {
$line =~ s/\(\s+\)/()/;
}
$line =~ s/SIP_FORCE//;
$line =~ s/SIP_DOC_TEMPLATE//;
return $line;
}

@@ -963,6 +966,28 @@ sub detect_non_method_member{
# remove export macro from struct definition
$LINE =~ s/^(\s*struct )\w+_EXPORT (.+)$/$1$2/;

# Skip comments
if ( $SUPPORT_TEMPLATE_DOCSTRING == 1 &&
$LINE =~ m/^\s*typedef\s+\w+\s*<\s*\w+\s*>\s+\w+\s+.*SIP_DOC_TEMPLATE/ ) {
# support Docstring for template based classes in SIP 4.19.7+
}
elsif ( $LINE =~ m/\/\// ||
$LINE =~ m/^\s*typedef / ||
$LINE =~ m/\s*struct / ||
$LINE =~ m/operator\[\]\(/ ||
$LINE =~ m/^\s*operator\b/ ||
$LINE =~ m/operator\s?[!+-=*\/\[\]<>]{1,2}/ ||
$LINE =~ m/^\s*%\w+(.*)?$/ ||
$LINE =~ m/^\s*namespace\s+\w+/ ||
$LINE =~ m/^\s*(virtual\s*)?~/ ||
detect_non_method_member() == 1 ){
dbg_info('skipping comment');
dbg_info('because typedef') if ($LINE =~ m/\s*typedef.*?(?!SIP_DOC_TEMPLATE)/);
$COMMENT = '';
$RETURN_TYPE = '';
$IS_OVERRIDE = 0;
}

$LINE = fix_annotations($LINE);

# fix astyle placing space after % character
@@ -1016,22 +1041,7 @@ sub detect_non_method_member{
# do not comment now for templates, wait for class definition
next;
}
if ( $LINE =~ m/\/\// ||
$LINE =~ m/\s*typedef / ||
$LINE =~ m/\s*struct / ||
$LINE =~ m/operator\[\]\(/ ||
$LINE =~ m/^\s*operator\b/ ||
$LINE =~ m/operator\s?[!+-=*\/\[\]<>]{1,2}/ ||
$LINE =~ m/^\s*%\w+(.*)?$/ ||
$LINE =~ m/^\s*namespace\s+\w+/ ||
$LINE =~ m/^\s*(virtual\s*)?~/ ||
detect_non_method_member() == 1 ){
dbg_info('skipping comment');
$COMMENT = '';
$RETURN_TYPE = '';
$IS_OVERRIDE = 0;
}
elsif ( $COMMENT !~ m/^\s*$/ || $RETURN_TYPE ne ''){
if ( $COMMENT !~ m/^\s*$/ || $RETURN_TYPE ne ''){
if ( $IS_OVERRIDE == 1 && $COMMENT =~ m/^\s*$/ ){
# overridden method with no new docs - so don't create a Docstring and use
# parent class Docstring
@@ -15,6 +15,16 @@
###########################################################################
set -e

TEMPLATE_DOC=""
while :; do
case $1 in
-t|--template-doc) TEMPLATE_DOC="-template-doc"
;;
*) break
esac
shift
done

DIR=$(git rev-parse --show-toplevel)

# GNU prefix command for mac os support (gsed, gsplit)
@@ -37,7 +47,7 @@ for module in "${modules[@]}"; do
else
path=$(${GP}sed -r 's@/[^/]+$@@' <<< $sipfile)
mkdir -p python/$path
./scripts/sipify.pl $header > python/$sipfile
./scripts/sipify.pl $TEMPLATE_DOC $header > python/$sipfile
fi
count=$((count+1))
done < <( ${GP}sed -n -r "s/^%Include (.*\.sip)/${module}\/\1/p" python/${module}/${module}_auto.sip )
@@ -184,4 +184,10 @@
*/
#define SIP_VIRTUAL_CATCHER_CODE(code)

/*
* Force documentation of templates
* Available for SIP 4.19.7+
*/
#define SIP_DOC_TEMPLATE

#endif // QGIS_SIP_H
@@ -412,7 +412,7 @@ class QgsTemporalRange
* \since QGIS 3.0
* \see QgsDateTimeRange
*/
typedef QgsTemporalRange< QDate > QgsDateRange;
typedef QgsTemporalRange< QDate > QgsDateRange SIP_DOC_TEMPLATE;

/**
* QgsRange which stores a range of date times.
@@ -424,6 +424,6 @@ typedef QgsTemporalRange< QDate > QgsDateRange;
* \since QGIS 3.0
* \see QgsDateRange
*/
typedef QgsTemporalRange< QDateTime > QgsDateTimeRange;
typedef QgsTemporalRange< QDateTime > QgsDateTimeRange SIP_DOC_TEMPLATE;

#endif // QGSRANGE_H

0 comments on commit 5327978

Please sign in to comment.
You can’t perform that action at this time.