File: multilang.lisp

package info (click to toggle)
acl2 8.6%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: sid
  • size: 1,138,276 kB
  • sloc: lisp: 17,818,294; java: 125,359; python: 28,122; javascript: 23,458; cpp: 18,851; ansic: 11,569; perl: 7,678; xml: 5,591; sh: 3,978; makefile: 3,840; ruby: 2,633; yacc: 1,126; ml: 763; awk: 295; csh: 233; lex: 197; php: 178; tcl: 49; asm: 23; haskell: 17
file content (47 lines) | stat: -rw-r--r-- 2,100 bytes parent folder | download | duplicates (2)
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
(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 を参照")))