Skip to content

Commit 6e99331

Browse files
authored
Adds a file to hold a map from class/method to headerfile (qgis#58054)
* create map file for class / header files for PyQGIS API docs * create map files * install file * add line numbers * also add methods * wait to sort * more methods * fix CMakeLists install * fix sorting * fix spell check * remove map files for Qt6 * Revert "remove map files for Qt6" This reverts commit 972f483. * do not test class_map files + auto sipify_all on branches * fix warning
1 parent c2660e2 commit 6e99331

File tree

15 files changed

+55278
-19
lines changed

15 files changed

+55278
-19
lines changed

.github/workflows/pr-fixer-bot.yml .github/workflows/sipify-bot.yml

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
1-
name: Run sipify on PR
1+
name: Run sipify
22

33
on:
44
issue_comment:
55
types: [created]
6+
push:
7+
branches:
8+
- master
9+
- release-*
610

711
jobs:
812
sipify:
9-
if: contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/sipify')
13+
if: github.event_name == 'push' || (contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/sipify'))
1014
runs-on: [ubuntu-latest]
1115
steps:
1216

1317
- name: Get PR branch
1418
uses: alessbell/[email protected]
19+
if: ${{ github.event_name == 'issue_comment' }}
1520
id: comment-branch
1621

1722
- uses: actions/checkout@v4
1823
with:
19-
ref: ${{ steps.comment-branch.outputs.head_ref }}
20-
repository: ${{ steps.comment-branch.outputs.head_owner }}/${{ steps.comment-branch.outputs.head_repo }}
24+
ref: ${{ steps.comment-branch.outputs.head_ref || github.ref_name }}
25+
repository: ${{ steps.comment-branch.outputs.head_owner || 'qgis' }}/${{ steps.comment-branch.outputs.head_repo || 'QGIS' }}
2126
token: ${{ secrets.GH_TOKEN_BOT }}
2227

2328
- name: Install Requirements
@@ -39,7 +44,7 @@ jobs:
3944
libtry-tiny-perl
4045
4146
- name: run sipify
42-
run: ./scripts/sipify_all.sh
47+
run: ./scripts/sipify_all.sh -m
4348

4449
- name: commit
4550
run: |

python/3d/class_map.yaml

+625
Large diffs are not rendered by default.

python/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,6 @@ foreach(module ${PY_MODULES})
449449
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${module}/auto_generated DESTINATION ${SIP_DEFAULT_SIP_DIR}/qgis/${module})
450450
endif()
451451
endforeach(module)
452+
453+
# install sipify config
454+
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sipify.yaml DESTINATION "${QGIS_PYTHON_DIR}")

python/PyQt6/3d/class_map.yaml

+625
Large diffs are not rendered by default.

python/PyQt6/analysis/class_map.yaml

+373
Large diffs are not rendered by default.

python/PyQt6/core/class_map.yaml

+18,796
Large diffs are not rendered by default.

python/PyQt6/gui/class_map.yaml

+7,452
Large diffs are not rendered by default.

python/PyQt6/server/class_map.yaml

+361
Large diffs are not rendered by default.

python/analysis/class_map.yaml

+373
Large diffs are not rendered by default.

python/core/class_map.yaml

+18,797
Large diffs are not rendered by default.

python/gui/class_map.yaml

+7,452
Large diffs are not rendered by default.

python/server/class_map.yaml

+361
Large diffs are not rendered by default.

scripts/sipify.pl

+18-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@
3434
my $sip_output = '';
3535
my $is_qt6 = 0;
3636
my $python_output = '';
37+
my $class_map_file = '';
3738
#my $SUPPORT_TEMPLATE_DOCSTRING = 0;
3839
#die("usage: $0 [-debug] [-template-doc] headerfile\n") unless GetOptions ("debug" => \$debug, "template-doc" => \$SUPPORT_TEMPLATE_DOCSTRING) && @ARGV == 1;
39-
die("usage: $0 [-debug] [-qt6] [-sip_output FILE] [-python_output FILE] headerfile\n")
40-
unless GetOptions ("debug" => \$debug, "sip_output=s" => \$sip_output, "python_output=s" => \$python_output, "qt6" => \$is_qt6) && @ARGV == 1;
40+
die("usage: $0 [-debug] [-qt6] [-sip_output FILE] [-python_output FILE] [-class_map FILE] headerfile\n")
41+
unless GetOptions ("debug" => \$debug, "sip_output=s" => \$sip_output, "python_output=s" => \$python_output, "qt6" => \$is_qt6, "class_map=s" => \$class_map_file) && @ARGV == 1;
4142
my $headerfile = $ARGV[0];
4243

4344
# read file
@@ -1400,6 +1401,12 @@ sub detect_non_method_member{
14001401
}
14011402
};
14021403
$LINE = "$1 $+{classname}";
1404+
# append to class map file
1405+
if ( $class_map_file ne '' ){
1406+
open(FH3, '>>', $class_map_file) or die $!;
1407+
print FH3 join(".", @CLASSNAME) . ": $headerfile#L".$LINE_IDX."\n";
1408+
close(FH3);
1409+
}
14031410
# Inheritance
14041411
if (defined $+{domain}){
14051412
my $m = $+{domain};
@@ -2001,6 +2008,15 @@ sub detect_non_method_member{
20012008

20022009
write_output("NOR", "$LINE\n");
20032010

2011+
# append to class map file
2012+
if ( $class_map_file ne '' && defined $ACTUAL_CLASS && $ACTUAL_CLASS ne '' ){
2013+
if ($LINE =~ m/^ *(const |virtual |static )* *[\w:]+ +\*?(?<method>\w+)\(.*$/){
2014+
open(FH3, '>>', $class_map_file) or die $!;
2015+
print FH3 join(".", @CLASSNAME) . "." . $+{method} .": $headerfile#L".$LINE_IDX."\n";
2016+
close(FH3);
2017+
}
2018+
}
2019+
20042020
if ($PYTHON_SIGNATURE ne '') {
20052021
write_output("PSI", "$PYTHON_SIGNATURE\n");
20062022
}

scripts/sipify_all.sh

+31-11
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@
1515
###########################################################################
1616
set -e
1717

18-
# TEMPLATE_DOC=""
19-
# while :; do
20-
# case $1 in
21-
# -t|--template-doc) TEMPLATE_DOC="-template-doc"
22-
# ;;
23-
# *) break
24-
# esac
25-
# shift
26-
# done
18+
CLASS_MAP=0
19+
while getopts "m" opt; do
20+
case $opt in
21+
m)
22+
CLASS_MAP=1
23+
;;
24+
\?)
25+
echo "Invalid option: -$OPTARG" >&2
26+
exit 1
27+
;;
28+
esac
29+
done
30+
shift $((OPTIND-1))
2731

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

@@ -50,9 +54,11 @@ for root_dir in python python/PyQt6; do
5054
fi
5155

5256
for module in "${modules[@]}"; do
53-
5457
module_dir=${root_dir}/${module}
5558

59+
rm ${module_dir}/class_map.yaml || true
60+
touch ${module_dir}/class_map.yaml
61+
5662
# clean auto_additions and auto_generated folders
5763
rm -rf ${module_dir}/auto_additions/*.py
5864
rm -rf ${module_dir}/auto_generated/*.py
@@ -71,14 +77,28 @@ It is not aimed to be manually edited
7177
else
7278
path=$(${GP}sed -r 's@/[^/]+$@@' <<< $sipfile)
7379
mkdir -p python/$path
74-
./scripts/sipify.pl $IS_QT6 -s ${root_dir}/$sipfile.in -p ${module_dir}/auto_additions/${pyfile} $header &
80+
CLASS_MAP_CALL=
81+
if [[ ${CLASS_MAP} -eq 1 ]]; then
82+
CLASS_MAP_CALL="-c ${module_dir}/class_map.yaml"
83+
fi
84+
./scripts/sipify.pl $IS_QT6 -s ${root_dir}/${sipfile}.in -p ${module_dir}/auto_additions/${pyfile} ${CLASS_MAP_CALL} ${header} &
7585
fi
7686
count=$((count+1))
7787
done < <( ${GP}sed -n -r "s@^%Include auto_generated/(.*\.sip)@${module}/auto_generated/\1@p" python/${module}/${module}_auto.sip )
7888
done
7989
done
8090
wait # wait for sipify processes to finish
8191

92+
if [[ ${CLASS_MAP} -eq 1 ]]; then
93+
for root_dir in python python/PyQt6; do
94+
for module in "${modules[@]}"; do
95+
module_dir=${root_dir}/${module}
96+
echo "sorting ${module_dir}/class_map.yaml"
97+
sort -n -o ${module_dir}/class_map.yaml ${module_dir}/class_map.yaml
98+
done
99+
done
100+
fi
101+
82102
echo " => $count files sipified! 🍺"
83103

84104
popd > /dev/null

scripts/spell_check/check_spelling.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
EXCLUDE_SCRIPT_LIST='(\.(xml|sip|pl|sh|badquote|cmake(\.in)?)|^(debian/copyright|cmake_templates/.*|tests/testdata/labeling/README.rst|tests/testdata/font/QGIS-Vera/COPYRIGHT.TXT|doc/debian/build/))$'
2727

2828
# always exclude these files
29-
EXCLUDE_EXTERNAL_LIST='((\.(svg|qgs|laz|las|png|lock|sip\.in))|resources/cpt-city-qgis-min/.*|resources/server/src/.*|resources/server/api/ogc/static/landingpage/js/.*|tests/testdata/.*|doc/api_break.dox|NEWS.md)$'
29+
EXCLUDE_EXTERNAL_LIST='((\.(svg|qgs|laz|las|png|lock|sip\.in))|resources/cpt-city-qgis-min/.*|resources/server/src/.*|resources/server/api/ogc/static/landingpage/js/.*|tests/testdata/.*|doc/api_break.dox|NEWS.md|python/.*/class_map.yaml)$'
3030

3131
DIR=$(git rev-parse --show-toplevel)/scripts/spell_check
3232

0 commit comments

Comments
 (0)