Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/BufFlatten.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:see-also: BufCompose, BufStats
:description:
Flatten a multichannel |buffer| to a single channel. This can be useful to structure a buffer such that it can be added to a :fluid-obj:`DataSet`

:discussion:
The ``axis`` argument determines how the flattening is arranged. The default value, 1, flattens channel-wise (similar to how audio files are stored), such that (if we imagine channels are rows, time positions are columns):

=== === ===
Expand Down
2 changes: 2 additions & 0 deletions flucoma/doc/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from markupsafe import Markup

from flucoma.doc.rst.docutils import register_custom_roles, register_custom_directives
from flucoma.doc.rst.html import no_rst_filter
from .logger import ContextView,add_context

def type_map(x,namer):
Expand All @@ -41,6 +42,7 @@ def setup_jinja(client_index, args, driver):
"""
# e.filters['rst'] = partial(rst_filter,data=client_index, driver=driver)
e.filters['rst'] = driver['rst_render']
e.filters['striprst'] = no_rst_filter
e.filters['as_host_object_name'] = lambda x: driver['namer'](client_index[x]) if x in client_index else f'Unresolved lookup ({x})'
e.filters['typename'] = partial(type_map, namer=driver['types'])
e.filters['constraints'] = lambda x,y,z: ''
Expand Down
51 changes: 50 additions & 1 deletion flucoma/doc/rst/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
from docutils import nodes
from docutils.utils import Reporter
from docutils.core import publish_parts
from docutils.writers import html4css1
from docutils.writers import html4css1, Writer


from functools import partial
from jinja2 import pass_context
from markupsafe import Markup

import logging
import re

class FlucomaCrossRefTranslator(html4css1.HTMLTranslator):
"""docutils translator for Max ref
Expand Down Expand Up @@ -96,3 +98,50 @@ def rst_filter(ctx,value):
settings_overrides=settings)

return Markup(tre['fragment'])


class RSTSripper(nodes.GenericNodeVisitor):

def __init__(self,document):
super(RSTSripper,self).__init__(document)
self.settings = settings = document.settings
self.body = []

def astext(self):
return ''.join(self.body)

def default_visit(self, node):
self.body.append(node.astext())
raise nodes.SkipNode

class NoRSTWriter(Writer):
def __init__(self):
super(NoRSTWriter,self).__init__()
self.translator_class = RSTSripper

def translate(self):
self.visitor = visitor = self.translator_class(self.document)
self.document.walkabout(visitor)
self.output = visitor.astext()

@pass_context
def no_rst_filter(ctx, value):
if value is None or len(value) == 0:
return ''
logging.debug('Parsing no-rst block')

driver = ctx.parent['driver']
index = ctx.parent['index']

value = re.sub(r'\|buffer\|','buffer~',value)

#stop docutils mirroing warnings to console, but we probably want to see errors
settings = {'report_level':Reporter.ERROR_LEVEL,'flucoma-host':ctx['host']}

tre = publish_parts(source=value,
writer = NoRSTWriter(),
reader = LoggingDocutilsReader(),
settings_overrides=settings)
return Markup(tre['whole'])


2 changes: 1 addition & 1 deletion flucoma/doc/templates/maxref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ under the European Union’s Horizon 2020 research and innovation programme
<!-- DO NOT EDIT THIS FILE ... YOU WILL LOSE YOUR WORK -->
<c74object name='{{ client_name | as_host_object_name }}' category='FluidCorpusManuipulation'>
<digest>{{ digest }}</digest>
<description>{{ description | rst }}</description>
<description>{{ description | striprst }}</description>
<discussion>
<h4><openfilelink filename="Fluid Corpus Manipulation Toolkit.maxpat">Open the Overview Patch</openfilelink></h4>
{{ discussion | rst | indent(8, first=True)}}
Expand Down