Skip to content

Commit

Permalink
🐛 main function was not narked as interractive
Browse files Browse the repository at this point in the history
  • Loading branch information
loispostula committed Nov 28, 2024
1 parent 5dbab93 commit bda373f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions terraform-docs.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; terraform-docs.el --- Integrate terraform-docs -*- lexical-binding: t; -*-

;; Author: Lo1s Postula <[email protected]>
;; Author: Lois Postula <[email protected]>
;; URL: https://github.com/loispostula/terraform-docs.el
;; Version: 0.1
;; Package-Requires: ((emacs "27.1"))
Expand All @@ -16,7 +16,7 @@
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; You should have received a copyof the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:
Expand Down Expand Up @@ -47,12 +47,13 @@ It will starts from START-DIR and searching upwards."
(when config-dir
(expand-file-name terraform-docs-config-name config-dir))))

(defun terraform-docs-run (&optional file-path stdout)
(defun terraform-docs (&optional file-path stdout)
"Run terraform-docs.
If FILE-PATH is provided, use it as the base path.
Otherwise, default to the current buffer.
If STDOUT is non-nil, return the output as a string
instead of using the user-defined configuration."
(interactive)
(let* ((file-path (or file-path (buffer-file-name)))
(current-dir (file-name-directory file-path))
(config-file (terraform-docs-config-file current-dir))
Expand All @@ -78,7 +79,7 @@ If STDOUT is non-nil, return the output as a string
If FILE-PATH is provided, use it as the base path.
Otherwise, default to the current buffer."
(interactive)
(let ((output (terraform-docs-run file-path t)))
(let ((output (terraform-docs file-path t)))
(with-output-to-temp-buffer "*terraform-docs-output*"
(princ output))))

Expand All @@ -95,7 +96,7 @@ If FILE-NAME is provided, use it as the output path.
(current-dir (file-name-directory file-path))
(directory-name (file-name-nondirectory (directory-file-name current-dir)))
(output-file (or file-name (expand-file-name (format "output-for-%s.md" directory-name) current-dir)))
(output (terraform-docs-run file-path t)))
(output (terraform-docs file-path t)))
(with-temp-file output-file
(insert output))
(message "Output written to %s" output-file)
Expand Down
4 changes: 2 additions & 2 deletions test/terraform-docs-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ Example of 'test' module.
(expand-file-name ".custom-docs-config.yml" terraform-docs-fixtures-dir)))
(delete-file (expand-file-name ".custom-docs-config.yml" terraform-docs-fixtures-dir))))))

(describe "terraform-docs-run"
(describe "terraform-docs"
(it "generates the expected output as a string"
(let* ((output (terraform-docs-run (expand-file-name "main.tf" terraform-docs-fixtures-dir) t))
(let* ((output (terraform-docs (expand-file-name "main.tf" terraform-docs-fixtures-dir) t))
(clean-output (terraform-docs-normalize-output (substring-no-properties output))))
(expect clean-output :to-equal terraform-docs-expected-output))))

Expand Down

0 comments on commit bda373f

Please sign in to comment.