Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@geographika
Copy link
Collaborator

What does this PR do?

Adds in a new ctest check to ensure docstub annotations can be correctly generated. If errors are introduced, the docs CI action will fail.

This will prevent invalid annotations being added to the Python docstrings, in preparation for creating stubs as part of the Python bindings.

If the CI fails then the errors will be reported in the logs similar to below:

2025-10-22T19:03:34.7781906Z 1392 matched annotations
2025-10-22T19:03:34.7782232Z 1 syntax errors
2025-10-22T19:03:34.7782538Z 30 unknown type names
2025-10-22T19:03:34.7782851Z   SpatialReference (x10)
..
2025-10-22T19:03:34.7784938Z   Feature (x1)
2025-10-22T19:03:34.7785237Z   datetime.datetime (x1)
2025-10-22T19:03:34.7785575Z   Transformer (x1)
2025-10-22T19:03:34.7785859Z 31 total errors
2025-10-22T19:03:34.7786030Z 
2025-10-22T19:03:34.7786152Z Finished in 11.006 s
2025-10-22T19:03:34.7786345Z 
2025-10-22T19:03:34.7786480Z Errors while running CTest
2025-10-22T19:03:34.7786700Z 
2025-10-22T19:03:34.7786861Z 0% tests passed, 1 tests failed out of 1
2025-10-22T19:03:34.7787144Z 
2025-10-22T19:03:34.7787235Z Total Test time (real) =  11.63 sec
2025-10-22T19:03:34.7787387Z 
2025-10-22T19:03:34.7787471Z The following tests FAILED:
2025-10-22T19:03:34.7787684Z 	  3 - docstub-annotations (Failed)

A few errors were introduced since #13198 was merged, and these have also been fixed.

What are related issues/pull requests?

#13198

@geographika geographika added funded through GSP Work funded through the GDAL Sponsorship Program Continuous integration documentation Issues and contributions to the documentation content labels Oct 22, 2025
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})

# Check docstub annotations
add_test(NAME docstub-annotations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command is actually generating the annotations, right? Would it make sense to register a custom target for the stub files, rather than going through ctest ? CI would still fail if the target cannot be built.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct - it will generate the stub files. I saw this PR as an intermediate step to ensure valid annotations until we are ready to package the stub files. The custom target would be better suited to gdal\swig\python\CMakeLists.txt rather than the gdal\doc\CMakeLists.txt one used here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd lean towards going straight for gdal/swig/python/CMakeLists.txt, yes.

The stub files aren't terribly useful until #13145 is done but they are at least able to provide return types. Should we go ahead and package them once 3.12 is separated from the master branch?

@coveralls
Copy link
Collaborator

coveralls commented Oct 22, 2025

Coverage Status

coverage: 71.349% (+0.02%) from 71.33%
when pulling 8f7df89 on geographika:docstub-checks
into 76318b2 on OSGeo:master.

@geographika
Copy link
Collaborator Author

@dbaston - I've added a new python_stub_files target, and tested it on build-windows-conda in the "Build and test with CMake" action.

Output is:

Run cmake --build $GITHUB_WORKSPACE/build --config Release -j 2 --target python_stub_files
[0/2] Re-checking globbed directories...
[1/2] C:\Windows\system32\cmd.exe /C "cd /D D:\a\gdal\gdal\build\swig\python && C:\Users\runneradmin\miniconda3\envs\gdalenv\python.exe -m docstub run D:/a/gdal/gdal/build/swig/python/osgeo --config D:/a/gdal/gdal/build/swig/python/pyproject.toml"
1423 matched annotations
0 total errors

Finished in 15.446 s

I'll need some guidance on where this should be added in the CI, and default build options.

  • A new CMake option BUILD_PYTHON_STUBS has been added, and set to OFF by default. I presume we don't want to set to ON until the stubs are useful?
  • https://pypi.org/project/docstub/#files - only has docstub-0.4.0.tar.gz available - so there is no Windows option (apart from through conda).

Once finalised, I presume I should remove the ctest code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Continuous integration documentation Issues and contributions to the documentation content funded through GSP Work funded through the GDAL Sponsorship Program

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants