Python console interactive help (Request in QGIS) #9384
Labels
3.42
QGIS 3.42 new features
Plugins
Core plugins, enhancement to handle community plugins
Project/Configuration
project properties, global options and settings
Milestone
Request for documentation
From pull request qgis/QGIS#58962
Author: @YoannQDQ
QGIS version: 3.42
Python console interactive help
PR Description:
Description
Add a shortcut in python editors to open the API
When pressing F1, open the API page matching
Behavior is slighltly different for the Python Console (and editors) and for the others generic QgsCodeEditorPython (e.g Expression Editor).
Generic editors
This PR only improves the already existing "Search in PyQGIS Documentation" action in the context menu to add the F1 shortcut and the word under mouse logic. Besides, if the text hovered matches a Qt class name, the Qt API is opened at the correct page. PyQGIS documentation urls cannot be deduced from the class name only as they also include the module name, so pressing F1 will only search the PyQGIS documentation.
Python console (where the PR truly shines)
Add a widget in the devtools panel to display the API documentation (PyQGIS and Qt)
The buttons at the top of the widget access the home pages of the APIs.
The button at the top right opens the current URL in the system web browser
When pressing F1 while hovering a symbol on the Python Console or Editors tab, the object is evaluated to get its class and module. The relevant API (PyQGIS or Qt) is then opened at the correct page. It works for class names, class, or even objects
Consider the following snippet:
Let's say the active layer is a vector layer. With the text cursor at the following words, pressing F1 will
myLayer
: open the PyQGIS api page for QgsVectorLayer.iface
: open the PyQGIS api page for QgisInterface.If the symbol is not recognized, open the PyQGIS API home page.
Settings
Demo
Commits tagged with [need-docs] or [FEATURE]
The text was updated successfully, but these errors were encountered: