File: multilang.lisp

package info (click to toggle)
acl2 8.5dfsg-5
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 991,452 kB
  • sloc: lisp: 15,567,759; javascript: 22,820; cpp: 13,929; ansic: 12,092; perl: 7,150; java: 4,405; xml: 3,884; makefile: 3,507; sh: 3,187; ruby: 2,633; ml: 763; python: 746; yacc: 723; awk: 295; csh: 186; php: 171; lex: 154; tcl: 49; asm: 23; haskell: 17
file content (53 lines) | stat: -rw-r--r-- 2,254 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#|
 This file is a part of documentation-utils
 (c) 2016 Shirakumo http://tymoon.eu (shinmera@tymoon.eu)
 Author: Nicolas Hafner <shinmera@tymoon.eu>
|#

(in-package #:org.shirakumo.documentation-utils)

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defclass multilang-formatter (documentation-formatter)
    ())

  (defmethod format-documentation ((formatter multilang-formatter) type var documentation)
    (let* ((documentation (etypecase documentation
                            (string (list (multilang-documentation:identifier multilang-documentation:*language*)
                                          documentation))
                            (cons documentation)))
           (docform (funcall (documentation-translator type) var))
           (default (loop for (lang docstring) on documentation by #'cddr
                          do (when (eq (multilang-documentation:language lang)
                                       multilang-documentation:*language*)
                               (return docstring))
                          finally (return (second docstring)))))
      (cond ((eq (first docform) 'documentation)
             `(progn
                ,@(loop for (lang docstring) on documentation by #'cddr
                        collect `(setf (multilang-documentation:documentation ,@(rest docform) :lang ',lang)
                                       ,docstring))
                ,default))
            (T
             (warn "Don't know how to deal with ~s. Can't expand to multilang definition." docform)
             default))))

  (export 'multilang-formatter))

(define-docs
  :formatter docs:multilang-formatter
  (type multilang-formatter
    (:en "This formatter allows specifying docstrings for multiple languages at once.

The docstring should be either just a single string like
always, in which case it is used for the default language,
or it should be a plist of languages and docstrings.

See DOCUMENTATION-FORMATTER
See MULTILANG-DOCUMENTATION:*LANGUAGE*
See MULTILANG-DOCUMENTATION:DOCUMENTATION"
     :jp "このformatterは複数の語のdocstring許します。

DOCUMENTATION-FORMATTER を参照
MULTILANG-DOCUMENTATION:*LANGUAGE* を参照
MULTILANG-DOCUMENTATION:DOCUMENTATION を参照")))