mirror of
https://github.com/godotengine/emacs-gdscript-mode.git
synced 2025-12-31 21:48:34 +03:00
Add an option to open a local build of the gdscript docs
This commit is contained in:
@@ -7,6 +7,11 @@ This document lists new features, improvements, changes, and bug fixes in each r
|
||||
### Features
|
||||
|
||||
- Support for running the project and scenes with [hydra](https://github.com/abo-abo/hydra) with `gdscript-hydra-show`.
|
||||
- Add the ability to open a local copy of the Godot docs with `gdscript-docs-*` commands.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
- Fixed auto-indentation not working with match blocks.
|
||||
|
||||
## GDScript mode 1.2.0
|
||||
|
||||
|
||||
@@ -117,5 +117,14 @@ PATH."
|
||||
"The path to the gdformat executable.
|
||||
By default, it assumes that the executable is in the system's
|
||||
PATH."
|
||||
:type 'string
|
||||
:group 'gdscript)
|
||||
|
||||
(defcustom gdscript-docs-local-path ""
|
||||
"Optional path to a local build of the Godot documentation.
|
||||
If not set to an empty string, the commands `gdscript-docs-browse-api'
|
||||
and `gdscript-docs-browse-symbol-at-point' allow you to browse the local files.
|
||||
Must be the root directory of the website, that is to say, a
|
||||
directory path containing the file `index.html'."
|
||||
:type 'string
|
||||
:group 'gdscript)
|
||||
|
||||
@@ -32,12 +32,15 @@
|
||||
;;; Code:
|
||||
|
||||
(require 'eww)
|
||||
(require 'gdscript-customization)
|
||||
|
||||
;;;###autoload
|
||||
(defun gdscript-docs-browse-api ()
|
||||
"Open the main page of Godot API in eww browser."
|
||||
(interactive)
|
||||
(eww-browse-url "https://docs.godotengine.org/en/stable/classes/index.html?#godot-api"))
|
||||
(if (not (string= gdscript-docs-local-path ""))
|
||||
(eww-open-file (concat (file-name-as-directory gdscript-docs-local-path) "classes/index.html"))
|
||||
(eww-browse-url "https://docs.godotengine.org/en/stable/classes/index.html?#godot-api")))
|
||||
|
||||
(defun gdscript-docs-browse-symbol-at-point ()
|
||||
"Open the API reference for the symbol at point in the browser eww.
|
||||
@@ -52,7 +55,9 @@ If a page is already open, switch to its buffer."
|
||||
(string-suffix-p symbol (plist-get eww-data :url) t)
|
||||
))) (buffer-list))))
|
||||
(if buffer (pop-to-buffer-same-window buffer)
|
||||
(eww-browse-url (format "https://docs.godotengine.org/en/stable/classes/class_%s.html#%s" symbol symbol) t))))
|
||||
(if (not (string= gdscript-docs-local-path ""))
|
||||
(eww-open-file (concat (file-name-as-directory gdscript-docs-local-path) (file-name-as-directory "classes") "class_" symbol ".html"))
|
||||
(eww-browse-url (format "https://docs.godotengine.org/en/stable/classes/class_%s.html#%s" symbol symbol) t)))))
|
||||
|
||||
(defun gdscript-docs--rename-eww-buffer ()
|
||||
"Rename the eww buffer visiting the Godot documentation.
|
||||
|
||||
Reference in New Issue
Block a user