aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorMichal Nazarewicz2020-04-26 19:30:41 +0100
committerMichal Nazarewicz2020-05-01 19:31:19 +0100
commit145aab0672ae259736ee9230f8e0ff4effa5f4fd (patch)
treeacb5fd9b9eda1a00d4dab0832c692e4f34e87f74 /lisp/progmodes
parent4b6c2bcecfe84585bae9fdfecbd87a48291793a5 (diff)
downloademacs-145aab0672ae259736ee9230f8e0ff4effa5f4fd.tar.gz
emacs-145aab0672ae259736ee9230f8e0ff4effa5f4fd.zip
cc-mode: add support for Doxygen documentation style
* lisp/progmodes/cc-fonts.el (doxygen-font-lock-doc-comments, doxygen-font-lock-keywords): New constants defining Doxygen comment style support. * lisp/progmodes/cc-vars.el (c-doc-comment-style): Updated docstring to mention now-supported Doxygen mode.
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/cc-fonts.el78
-rw-r--r--lisp/progmodes/cc-vars.el1
2 files changed, 79 insertions, 0 deletions
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index 2cbbc66c14f..9ea08a46244 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -3016,6 +3016,84 @@ need for `pike-font-lock-extra-types'.")
3016 (c-font-lock-doc-comments "/[*/]!" limit 3016 (c-font-lock-doc-comments "/[*/]!" limit
3017 autodoc-font-lock-doc-comments))))) 3017 autodoc-font-lock-doc-comments)))))
3018 3018
3019;; Doxygen
3020
3021(defconst doxygen-font-lock-doc-comments
3022 ;; TODO: Handle @code, @verbatim, @dot, @f etc. better by not highlighting
3023 ;; text inside of those commands. Something smarter than just regexes may be
3024 ;; needed to do that efficiently.
3025 `((,(concat
3026 ;; Make sure that the special character has not been escaped. E.g. in
3027 ;; ‘\@foo’ only ‘\@’ is a command (similarly for other characters like
3028 ;; ‘\\foo’, ‘\<foo’ and ‘\&foo’). The downside now is that we don’t
3029 ;; match command started just after an escaped character, e.g. in
3030 ;; ‘\@\foo’ we should match ‘\@’ as well as ‘\foo’ but only the former
3031 ;; is matched.
3032 "\\(?:^\\|[^\\@]\\)\\("
3033 ;; Doxygen commands start with backslash or an at sign. Note that for
3034 ;; brevity in the comments only ‘\’ will be mentioned.
3035 "[\\@]\\(?:"
3036 ;; Doxygen commands except those starting with ‘f’
3037 "[a-eg-z][a-z]*"
3038 ;; Doxygen command starting with ‘f’:
3039 "\\|f\\(?:"
3040 "[][$}]" ; \f$ \f} \f[ \f]
3041 "\\|{\\(?:[a-zA-Z]+\\*?}{?\\)?" ; \f{ \f{env} \f{env}{
3042 "\\|[a-z]+" ; \foo
3043 "\\)"
3044 "\\|~[a-zA-Z]*" ; \~ \~language
3045 "\\|[$@&~<=>#%\".|\\\\]" ; single-character escapes
3046 "\\|::\\|---?" ; \:: \-- \---
3047 "\\)"
3048 ;; HTML tags and entities:
3049 "\\|</?\\sw\\(?:\\sw\\|\\s \\|[=\n\r*.:]\\|\"[^\"]*\"\\|'[^']*'\\)*>"
3050 "\\|&\\(?:\\sw+\\|#[0-9]+\\|#x[0-9a-fA-F]+\\);"
3051 "\\)")
3052 1 ,c-doc-markup-face-name prepend nil)
3053 ;; Commands inside of strings are not commands so override highlighting with
3054 ;; string face. This also affects HTML attribute values if they are
3055 ;; surrounded with double quotes which may or may not be considered a good
3056 ;; thing.
3057 ("\\(?:^\\|[^\\@]\\)\\(\"[^\"[:cntrl:]]+\"\\)"
3058 1 font-lock-string-face prepend nil)
3059 ;; HTML comments inside of the Doxygen comments.
3060 ("\\(?:^\\|[^\\@]\\)\\(<!--.*?-->\\)"
3061 1 font-lock-comment-face prepend nil)
3062 ;; Autolinking. Doxygen auto-links anything that is a class name but we have
3063 ;; no hope of matching those. We are, however, able to match functions and
3064 ;; members using explicit scoped syntax. For functions, we can also find
3065 ;; them by noticing argument-list. Note that Doxygen accepts ‘::’ as well
3066 ;; as ‘#’ as scope operators.
3067 (,(let* ((ref "[\\@]ref\\s-+")
3068 (ref-opt (concat "\\(?:" ref "\\)?"))
3069 (id "[a-zA-Z_][a-zA-Z_0-9]*")
3070 (args "\\(?:()\\|([^()]*)\\)")
3071 (scope "\\(?:#\\|::\\)"))
3072 (concat
3073 "\\(?:^\\|[^\\@/%:]\\)\\(?:"
3074 ref-opt "\\(?1:" scope "?" "\\(?:" id scope "\\)+" "~?" id "\\)"
3075 "\\|" ref-opt "\\(?1:" scope "~?" id "\\)"
3076 "\\|" ref-opt "\\(?1:" scope "?" "~?" id "\\)" args
3077 "\\|" ref "\\(?1:" "~?" id "\\)"
3078 "\\|" ref-opt "\\(?1:~[A-Z][a-zA-Z0-9_]+\\)"
3079 "\\)"))
3080 1 font-lock-function-name-face prepend nil)
3081 ;; Match URLs and emails. This has two purposes. First of all, Doxygen
3082 ;; autolinks URLs. Second of all, ‘@bar’ in ‘foo@bar.baz’ has been matched
3083 ;; above as a command; try and overwrite it.
3084 (,(let* ((host "[A-Za-z0-9]\\(?:[A-Za-z0-9-]\\{0,61\\}[A-Za-z0-9]\\)")
3085 (fqdn (concat "\\(?:" host "\\.\\)+" host))
3086 (comp "[!-(*--/-=?-~]+")
3087 (path (concat "/\\(?:" comp "[.]+" "\\)*" comp)))
3088 (concat "\\(?:mailto:\\)?[a-zA-0_.]+@" fqdn
3089 "\\|https?://" fqdn "\\(?:" path "\\)?"))
3090 0 font-lock-keyword-face prepend nil)))
3091
3092(defconst doxygen-font-lock-keywords
3093 `((,(lambda (limit)
3094 (c-font-lock-doc-comments "/\\(?:/[/!]\\|\\*[\\*!]\\)"
3095 limit doxygen-font-lock-doc-comments)))))
3096
3019 3097
3020;; 2006-07-10: awk-font-lock-keywords has been moved back to cc-awk.el. 3098;; 2006-07-10: awk-font-lock-keywords has been moved back to cc-awk.el.
3021(cc-provide 'cc-fonts) 3099(cc-provide 'cc-fonts)
diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el
index 3995b211854..b885f6ae1d8 100644
--- a/lisp/progmodes/cc-vars.el
+++ b/lisp/progmodes/cc-vars.el
@@ -576,6 +576,7 @@ comment styles:
576 javadoc -- Javadoc style for \"/** ... */\" comments (default in Java mode). 576 javadoc -- Javadoc style for \"/** ... */\" comments (default in Java mode).
577 autodoc -- Pike autodoc style for \"//! ...\" comments (default in Pike mode). 577 autodoc -- Pike autodoc style for \"//! ...\" comments (default in Pike mode).
578 gtkdoc -- GtkDoc style for \"/** ... **/\" comments (default in C and C++ modes). 578 gtkdoc -- GtkDoc style for \"/** ... **/\" comments (default in C and C++ modes).
579 doxygen -- Doxygen style.
579 580
580The value may also be a list of doc comment styles, in which case all 581The value may also be a list of doc comment styles, in which case all
581of them are recognized simultaneously (presumably with markup cues 582of them are recognized simultaneously (presumably with markup cues