From d1ed01519655b6b262d6d21cdfb29f166b697eb3 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 7 Jun 2015 13:50:40 +0200 Subject: Distinguish face for doc-comments Using the syntactic-face-function, we can assign the proper `font-lock-doc-face' to doc comments ("///", "//!", "/**", "/*!"). Test changes graciously copied from https://github.com/rust-lang/rust-mode/pull/64 --- rust-mode-tests.el | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'rust-mode-tests.el') diff --git a/rust-mode-tests.el b/rust-mode-tests.el index b40aed0..58fcaaf 100644 --- a/rust-mode-tests.el +++ b/rust-mode-tests.el @@ -1085,6 +1085,70 @@ this_is_not_a_string();)" (should (equal nil (get-text-property 28 'face))) ;; Semicolon--should not be part of the string )) +;;; Documentation comments + +(ert-deftest font-lock-doc-line-comment-parent () + (rust-test-font-lock + "//! doc" + '("//! doc" font-lock-doc-face))) + +(ert-deftest font-lock-doc-line-comment-item () + (rust-test-font-lock + "/// doc" + '("/// doc" font-lock-doc-face))) + +(ert-deftest font-lock-nondoc-line () + (rust-test-font-lock + "////// doc" + '("////// " font-lock-comment-delimiter-face + "doc" font-lock-comment-face))) + +(ert-deftest font-lock-doc-line-in-string () + (rust-test-font-lock + "\"/// doc\"" + '("\"/// doc\"" font-lock-string-face)) + + (rust-test-font-lock + "\"//! doc\"" + '("\"//! doc\"" font-lock-string-face))) + +(ert-deftest font-lock-doc-line-in-nested-comment () + (rust-test-font-lock + "/* /// doc */" + '("/* " font-lock-comment-delimiter-face + "/// doc */" font-lock-comment-face)) + + (rust-test-font-lock + "/* //! doc */" + '("/* " font-lock-comment-delimiter-face + "//! doc */" font-lock-comment-face))) + + +(ert-deftest font-lock-doc-block-comment-parent () + (rust-test-font-lock + "/*! doc */" + '("/*! doc */" font-lock-doc-face))) + +(ert-deftest font-lock-doc-block-comment-item () + (rust-test-font-lock + "/** doc */" + '("/** doc */" font-lock-doc-face))) + +(ert-deftest font-lock-nondoc-block-comment-item () + (rust-test-font-lock + "/***** doc */" + '("/**" font-lock-comment-delimiter-face + "*** doc */" font-lock-comment-face))) + +(ert-deftest font-lock-doc-block-in-string () + (rust-test-font-lock + "\"/** doc */\"" + '("\"/** doc */\"" font-lock-string-face)) + (rust-test-font-lock + "\"/*! doc */\"" + '("\"/*! doc */\"" font-lock-string-face))) + + (ert-deftest indent-method-chains-no-align () (let ((rust-indent-method-chain nil)) (test-indent " -- cgit v1.2.3