1 | from docutils import nodes |
---|
2 | from docutils.parsers.rst import directives |
---|
3 | |
---|
4 | from sphinx import addnodes |
---|
5 | from sphinx.roles import XRefRole |
---|
6 | from sphinx.locale import l_, _ |
---|
7 | from sphinx.directives import ObjectDescription |
---|
8 | from sphinx.domains import Domain, ObjType, Index |
---|
9 | from sphinx.util.nodes import make_refnode |
---|
10 | from sphinx.util.docfields import Field, TypedField |
---|
11 | |
---|
12 | """ |
---|
13 | :r:bsp:`sparc/sis` |
---|
14 | |
---|
15 | :r:arch:`sparc` |
---|
16 | |
---|
17 | :r:board:`...` |
---|
18 | |
---|
19 | :r:user:`amar` |
---|
20 | |
---|
21 | :r:list:`devel` |
---|
22 | """ |
---|
23 | |
---|
24 | role_name = { |
---|
25 | "bsp": "BSP", |
---|
26 | "arch": "Architecture", |
---|
27 | "board": "Board", |
---|
28 | "user": "User", |
---|
29 | "list": "Mailing List", |
---|
30 | "rtems": "`RTEMS`", |
---|
31 | } |
---|
32 | |
---|
33 | role_url = { |
---|
34 | "trac": ("Trac", "https://devel.rtems.org"), |
---|
35 | "devel": ("Developer Site", "https://devel.rtems.org"), |
---|
36 | "www": ("RTEMS Home", "https://www.rtems.org/"), |
---|
37 | "buildbot": ("Buildbot Instance", "https://buildbot.rtems.org/"), |
---|
38 | "builder": ("Builder Site", "https://builder.rtems.org/"), |
---|
39 | "docs": ("Documentation Site", "https://docs.rtems.org/"), |
---|
40 | "lists": ("Mailing Lists", "https://lists.rtems.org/"), |
---|
41 | "git": ("Git Repositories", "https://git.rtems.org/"), |
---|
42 | "ftp": ("FTP File Server", "https://ftp.rtems.org/"), |
---|
43 | "review": ("Gerrit Code Review", "https://review.rtems.org/"), |
---|
44 | "bugs": ("Bugs Database", "https://devel.rtems.org/wiki/Bugs/"), |
---|
45 | "gsoc": ("Google Summer of Code", "https://devel.rtems.org/wiki/GSoC/"), |
---|
46 | "socis": ("ESA SOCIS", "https://devel.rtems.org/wiki/SOCIS/"), |
---|
47 | "bsp-howto": ("RTEMS BSP and Driver Guide", "https://docs.rtems.org/branches/master/bsp-howto/index.html"), |
---|
48 | "cpu-supplement": ("RTEMS CPU Architecture Supplement", "https://docs.rtems.org/branches/master/cpu-supplement/index.html"), |
---|
49 | "c-user": ("RTEMS Classic API Guide", "https://docs.rtems.org/branches/master/c-user/index.html"), |
---|
50 | "develenv": ("RTEMS Development Environment Guide", "https://docs.rtems.org/branches/master/develenv/index.html"), |
---|
51 | "eclipse": ("RTEMS Eclipse Manual", "https://docs.rtems.org/branches/master/eclipse/index.html"), |
---|
52 | "eng": ("RTEMS Software Engineering", "https://docs.rtems.org/branches/master/eng/index.html"), |
---|
53 | "filesystem": ("RTEMS Filesystem Design Guide", "https://docs.rtems.org/branches/master/filesystem/index.html"), |
---|
54 | "networking": ("RTEMS Networking User Manual", "https://docs.rtems.org/branches/master/networking/index.html"), |
---|
55 | "posix-compliance": ("RTEMS POSIX 1003.1 Compliance Guide", "https://docs.rtems.org/branches/master/posix-compliance/index.html"), |
---|
56 | "posix-users": ("RTEMS POSIX API Guide", "https://docs.rtems.org/branches/master/posix-users/index.html"), |
---|
57 | "shell": ("RTEMS Shell Guide", "https://docs.rtems.org/branches/master/shell/index.html"), |
---|
58 | "user": ("RTEMS User Manual", "https://docs.rtems.org/branches/master/user/index.html"), |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | role_list = { |
---|
63 | "announce": ("Announce Mailing List", "https://lists.rtems.org/mailman/listinfo/announce/"), |
---|
64 | "bugs": ("Bugs Mailing List", "https://lists.rtems.org/mailman/listinfo/bugs/"), |
---|
65 | "devel": ("Developers Mailing List", "https://lists.rtems.org/mailman/listinfo/devel/"), |
---|
66 | "build": ("Build Logs", "https://lists.rtems.org/mailman/listinfo/build"), |
---|
67 | "users": ("Users Mailing List", "https://lists.rtems.org/mailman/listinfo/users/"), |
---|
68 | "vc": ("Version Control Mailing List", "https://lists.rtems.org/mailman/listinfo/vc/"), |
---|
69 | } |
---|
70 | |
---|
71 | |
---|
72 | def rtems_resolve_role(name, rawtext, text, lineno, inliner, options={}, content=[]): |
---|
73 | role = name.split(":")[1] #XXX: is there a better way? |
---|
74 | |
---|
75 | try: |
---|
76 | if role == "list": |
---|
77 | text, url = role_list[text] |
---|
78 | elif role == "url": |
---|
79 | text, url = role_url[text] |
---|
80 | except KeyError: |
---|
81 | msg = inliner.reporter.error("rtems_resolve_role: '%s' is not a valid %s" % (text, role)) |
---|
82 | err = inliner.problematic("ERROR: %s" % rawtext, None, msg) |
---|
83 | return [err], [msg] |
---|
84 | |
---|
85 | # XXX: how do you add an alt tag? |
---|
86 | node = nodes.reference(rawtext, text, refuri=url, **options) |
---|
87 | return [node], [] |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | class RTEMSXrefRole(XRefRole): |
---|
92 | def __init__(self, item, title, **kwargs): |
---|
93 | XRefRole.__init__(self, **kwargs) |
---|
94 | self.item = item |
---|
95 | self.title = title |
---|
96 | |
---|
97 | def process_link(self, env, refnode, has_explicit_title, title, target): |
---|
98 | if has_explicit_title: |
---|
99 | title = has_explicit_title |
---|
100 | |
---|
101 | return has_explicit_title or self.title, target |
---|
102 | |
---|
103 | |
---|
104 | |
---|
105 | |
---|
106 | class RTEMSDomain(Domain): |
---|
107 | """RTEMS domain.""" |
---|
108 | |
---|
109 | name = "r" |
---|
110 | label = "RTEMS" |
---|
111 | |
---|
112 | directives = {} |
---|
113 | object_types = {} |
---|
114 | |
---|
115 | roles = { |
---|
116 | "bsp": RTEMSXrefRole("bsp", "BSP"), |
---|
117 | "arch": RTEMSXrefRole("arch", "Architecture"), |
---|
118 | "user": RTEMSXrefRole("user", "User"), |
---|
119 | "list": rtems_resolve_role, |
---|
120 | "url": rtems_resolve_role, |
---|
121 | } |
---|
122 | |
---|
123 | |
---|
124 | def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode): |
---|
125 | info = "*info*" |
---|
126 | anchor = "*anchor*" |
---|
127 | title = "*title*" |
---|
128 | |
---|
129 | return make_refnode(builder, fromdocname, info, anchor, contnode, title) |
---|
130 | |
---|
131 | def merge_domaindata(self, docnames, otherdata): |
---|
132 | pass # XXX is this needed? |
---|
133 | |
---|
134 | |
---|
135 | |
---|
136 | def setup(app): |
---|
137 | app.add_domain(RTEMSDomain) |
---|
138 | return {'version': "1.0", 'parallel_read_safe': True} |
---|