Skip to content

Commit 5065a5d

Browse files
committed
refs #24 update all nekochan directive
1 parent 211bd8a commit 5065a5d

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

sphinx_nekochan/__init__.py

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -155,26 +155,38 @@ def run(self) -> list[nodes.Node]:
155155
nekochan_emoji, _ = get_nekochan_emoji_data()
156156

157157
text = f"Number of Nekochan emojis: {len(nekochan_emoji)}"
158-
node_list.append(nodes.Text(text))
158+
paragraph = nodes.paragraph()
159+
paragraph.append(nodes.Text(text))
160+
node_list.append(paragraph)
161+
162+
# add div
163+
container = nodes.container()
164+
container.attributes["ids"] = ["nekochan"]
165+
search_text = '<input class="search" placeholder="Search" />'
166+
search = nodes.raw("", nodes.Text(search_text), format="html")
167+
container.append(search)
168+
169+
# create table and header
170+
table, tgroup = self.create_table_header()
171+
tbody = nodes.tbody()
172+
tgroup += tbody
173+
174+
container.append(table)
175+
node_list.append(container)
159176

160-
first_char = ""
161177
for name, data in nekochan_emoji.items():
162-
if name[0] != first_char:
163-
first_char = name[0]
164-
# create section and title(H2)
165-
section = nodes.section(ids=[first_char])
166-
title = nodes.title(first_char.upper(), first_char.upper())
167-
section.append(title)
168-
node_list.append(section)
169-
170-
# create table and header
171-
table, tgroup = self.create_table_header()
172-
tbody = nodes.tbody()
173-
tgroup += tbody
174-
node_list.append(table)
175178
# add row to table
176179
tbody += self.create_row(name, nekochan_emoji[name]["aliases"])
177180

181+
# add javascript
182+
js = """
183+
var options = {valueNames: ['name', 'aliases']};
184+
var userList = new List('users', options);
185+
</script>"""
186+
search_text = '<input class="search" placeholder="Search" />'
187+
js_node = nodes.raw("", nodes.Text(js), format="html")
188+
container.append(js_node)
189+
178190
return node_list
179191

180192
def create_table_header(self) -> nodes.Node:
@@ -218,12 +230,14 @@ def create_row(self, name: str, aliases) -> nodes.Node:
218230
cell = nodes.entry()
219231
row += cell
220232
cell += nodes.literal(name, name)
233+
cell.set_class("name")
221234
cell = nodes.entry()
222235
row += cell
223236
for idx, alias in enumerate(aliases):
224237
if idx > 0:
225238
cell += nodes.Text(", ")
226239
cell += nodes.literal(alias, alias)
240+
cell.set_class("aliaess")
227241

228242
return row
229243

0 commit comments

Comments
 (0)