diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ef0d16..150d55c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/gdscript-customization.el b/gdscript-customization.el index 6e01b5a..97e85aa 100644 --- a/gdscript-customization.el +++ b/gdscript-customization.el @@ -117,5 +117,14 @@ 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) + (provide 'gdscript-customization) ;;; gdscript-customization.el ends here diff --git a/gdscript-docs.el b/gdscript-docs.el index 2bfde13..5932092 100644 --- a/gdscript-docs.el +++ b/gdscript-docs.el @@ -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.