Skip to content
This repository was archived by the owner on Mar 5, 2024. It is now read-only.

Commit be5798f

Browse files
committed
Revert prior two commits because of breakage on non-html builders
1 parent 627a593 commit be5798f

File tree

14 files changed

+64
-265
lines changed

14 files changed

+64
-265
lines changed

sphinxext/codepen.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

sphinxext/fixed_only.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import logging
12
from docutils import nodes
23
from docutils.parsers.rst import Directive, directives
34
from sphinx.util.nodes import nested_parse_with_titles
45

6+
logger = logging.getLogger('fasthtml')
7+
58

69
class Cond(Directive):
710
"""

sphinxext/mongodb.py

Lines changed: 7 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from docutils.parsers.rst import directives
1919

2020
import sphinx
21-
import sphinx.directives.code
2221
from sphinx.domains import Domain, ObjType
2322
from sphinx.locale import l_, _
2423
from sphinx.directives import ObjectDescription
@@ -30,17 +29,14 @@
3029

3130
from mongodb_conf import conf
3231

33-
3432
def make_index_entry(*args):
3533
"""Sphinx 1.4 makes a breaking change in index format, so return a valid
3634
index entry whichever version we're running."""
3735
return args + (None,) if sphinx.version_info >= (1, 4) else args
3836

39-
4037
def basename(path):
4138
return os.path.splitext(os.path.basename(path))[0]
4239

43-
4440
class MongoDBObject(ObjectDescription):
4541
"""
4642
Description of a MongoDB object.
@@ -161,6 +157,7 @@ def add_target_and_index(self, name_obj, sig, signode):
161157
else:
162158
objects[fullname] = self.env.docname, self.objtype
163159

160+
164161
indextext = self.get_index_text(objectname, name_obj)
165162
if indextext:
166163
self.indexnode['entries'].append(
@@ -213,11 +210,9 @@ def run(self):
213210
names=('rtype',)),
214211
]
215212

216-
217213
class MongoDBMethod(MongoDBObject):
218214
has_arguments = True
219215

220-
221216
class MongoDBXRefRole(XRefRole):
222217
def process_link(self, env, refnode, has_explicit_title, title, target):
223218
# basically what sphinx.domains.python.PyXRefRole does
@@ -235,11 +230,10 @@ def process_link(self, env, refnode, has_explicit_title, title, target):
235230
refnode['refspecific'] = True
236231
return title, target
237232

238-
239233
def render_domain_data(mongodb_directives):
240-
directives = {}
241-
roles = {}
242-
object_types = {}
234+
directives = { }
235+
roles = { }
236+
object_types = { }
243237

244238
for directive in mongodb_directives:
245239
reftype = directive['name']
@@ -254,7 +248,6 @@ def render_domain_data(mongodb_directives):
254248

255249
return directives, roles, object_types
256250

257-
258251
class MongoDBDomain(Domain):
259252
"""MongoDB Documentation domain."""
260253
name = 'mongodb'
@@ -264,7 +257,7 @@ class MongoDBDomain(Domain):
264257
directives, roles, object_types = render_domain_data(conf['directives'])
265258

266259
initial_data = {
267-
'objects': {}, # fullname -> docname, objtype
260+
'objects': {}, # fullname -> docname, objtype
268261
}
269262

270263
def find_obj(self, env, obj, name, typ, searchorder=0):
@@ -343,114 +336,11 @@ def run(self):
343336
return result
344337

345338

346-
class code_button_row(nodes.Element):
347-
pass
348-
349-
350-
def visit_code_button_row(self, node):
351-
start_tag = self.starttag(node, 'div', CLASS='button-row')
352-
self.body.append(start_tag)
353-
354-
355-
def depart_code_button_row(self, node):
356-
self.body.append('</div>\n')
357-
358-
359-
class code_button(nodes.Element):
360-
pass
361-
362-
363-
def visit_code_button(self, node):
364-
href = node.get('href', False)
365-
css_class = ' '.join(['code-button'] + node.get('classes', []))
366-
367-
if href:
368-
start_tag = self.starttag(node, 'a', CLASS=css_class, role='button', href=href, target='_blank')
369-
else:
370-
start_tag = self.starttag(node, 'a', CLASS=css_class, role='button')
371-
372-
self.body.append(start_tag)
373-
374-
375-
def depart_code_button(self, node):
376-
self.body.append(node['text'][0] + '</a>\n')
377-
378-
379-
class code_container(nodes.Element):
380-
pass
381-
382-
383-
def visit_code_container(self, node):
384-
start_tag = self.starttag(node, 'div', CLASS='button-code-block')
385-
self.body.append(start_tag)
386-
387-
388-
def depart_code_container(self, node):
389-
self.body.append('</div>\n')
390-
391-
392-
def create_button(button_type, link, classes=[]):
393-
"""Create a button inside of a code block with the given label and link."""
394-
button = code_button('')
395-
button['text'] = [button_type]
396-
button['classes'] = classes
397-
398-
if link:
399-
button['href'] = [link]
400-
401-
return button
402-
403-
404-
class CodeBlock(sphinx.directives.code.CodeBlock):
405-
"""
406-
Add copy, show in stitch, and github buttons to code block.
407-
"""
408-
option_spec = sphinx.directives.code.CodeBlock.option_spec.copy()
409-
option_spec.update({
410-
'button-github': directives.uri,
411-
'button-stitch': directives.uri,
412-
'copyable': lambda argument: directives.choice(argument,
413-
('true', 'false', None)),
414-
})
415-
416-
def run(self):
417-
options = self.options
418-
419-
container = code_container('')
420-
codeblock = sphinx.directives.code.CodeBlock.run(self)
421-
br = code_button_row('')
422-
423-
if options.get('copyable', 'true') != 'false':
424-
codeblock[0]['classes'] += ['copyable-code-block']
425-
br += create_button('copy', False, ['code-button--copy'])
426-
427-
if options.get('button-github'):
428-
br += create_button('github', options['button-github'])
429-
430-
if options.get('button-stitch'):
431-
br += create_button('stitch', options['button-stitch'])
432-
433-
container += br
434-
container += codeblock
435-
return [container]
436-
437-
438339
def setup(app):
439340
app.add_domain(MongoDBDomain)
440341
directives.register_directive('figure', ExtendedFigure)
441342

442-
app.add_node(code_button_row, html=(
443-
visit_code_button_row, depart_code_button_row
444-
))
445-
app.add_node(code_button, html=(
446-
visit_code_button, depart_code_button
447-
))
448-
app.add_node(code_container, html=(
449-
visit_code_container, depart_code_container
450-
))
451-
directives.register_directive('code-block', CodeBlock)
452-
453343
# Do NOT turn on parallel reads until we know what's causing massive
454344
# (2+ GB per worker) memory bloat and thrashing.
455-
return {'parallel_read_safe': False,
456-
'parallel_write_safe': True}
345+
return { 'parallel_read_safe': False,
346+
'parallel_write_safe': True }

themes/mongodb/src/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ CSS_INPUTS=css/bootstrap-custom.css \
66
css/feedback.css \
77
css/header.css \
88
css/mws.css \
9+
css/copy-button.css \
910
css/tabs.css \
10-
css/lightbox.css \
11-
css/code-buttons.css
11+
css/lightbox.css
1212
CSS_FILES=$(CSS_INPUTS) css/basic.css
1313

1414
CSS_ERRORS=errors,empty-rules,duplicate-properties,selector-max-approaching

themes/mongodb/src/css/code-buttons.css

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.copy-button-container {
2+
width: 0;
3+
height: 0;
4+
position: relative;
5+
width: 100%;
6+
}
7+
8+
.copy-button {
9+
border: 1px solid #7a7b7b;
10+
background-color: #7a7b7b;
11+
color: white;
12+
height: 25px;
13+
width: 65px;
14+
font-size: 13px;
15+
left: calc(100% - 65px);
16+
position: absolute;
17+
}
18+
19+
@media print {
20+
.copy-button-container {
21+
display: none;
22+
}
23+
}
24+
25+
.copy-button:active {
26+
background-color: rgb(157, 158, 158);
27+
border-color: rgb(157, 158, 158);
28+
}
29+
30+
.copy-button > .fa {
31+
padding-right: 3px;
32+
}

themes/mongodb/src/js/componentCodepen.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)