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
14 changes: 14 additions & 0 deletions flucoma/doc/learn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import re

def derive_learn_link(object_name):
"""
Derive a url of the relevant reference in the learn platform from the object name.
Uses a regular expression to capture oddballs where you want to keep "Buf" as a prefix to the object name.
"""

# If you need to add an edge case add another item to this regex
m = re.search('(?:Buf)(?!NMF|Compose|Flatten|Scale)(.+)', object_name)
if m:
return m.group(1).lower()
else:
return object_name.lower()
2 changes: 2 additions & 0 deletions flucoma/doc/sc/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from docutils import nodes
from collections import OrderedDict
from ..transformers import tidy_split, filter_fixed_controls
from flucoma.doc.learn import derive_learn_link
from flucoma.doc.rst.scdoc import SCDocWriter,rst_filter
from .defaults import defaults
import copy
Expand Down Expand Up @@ -55,6 +56,7 @@ def sc_type_map(type):

def sc_transform_data(object_name,data):
data['client_name'] = object_name
data['learn_url'] = 'https://learn.flucoma.org/reference/' + derive_learn_link(object_name)
data['category'] = []
data['keywords'] = []
data['module'] = ''
Expand Down
1 change: 1 addition & 0 deletions flucoma/doc/templates/cli_htmlref.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ <h2>Description</h2>
<section class="object_discussion">
<h2>Discussion</h2>
<p>{{ discussion|rst }}</p>
<p>Read more about {{ client_name | as_host_object_name }} on the <a href='{{ learn_url | e }}'>learn platform</a>.</p>
<p>{{ client_name | as_host_object_name }} is part of the Fluid Decomposition Toolkit of the FluCoMa project. For more explanations, learning material, and discussions on its musicianly uses, visit <a href="http://www.flucoma.org/">flucoma.org</a>.</p>
</section>
<section class="attribute_section">
Expand Down
8 changes: 4 additions & 4 deletions flucoma/doc/templates/maxref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ under the European Union’s Horizon 2020 research and innovation programme
<digest>{{ digest }}</digest>
<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)}}

{{ client_name | as_host_object_name }} is part of the Fluid Decomposition Toolkit of the FluCoMa project. For more explanations, learning material, and discussions on its musicianly uses, visit <a href="http://www.flucoma.org/">flucoma.org</a>.
<h4><openfilelink filename="Fluid Corpus Manipulation Toolkit.maxpat">Open the Overview Patch</openfilelink></h4>
{{ discussion | rst | indent(8, first=True)}}
<p>Read more about {{ client_name | as_host_object_name }} on the <a href='{{ learn_url | e }}'>learn platform</a>.</p>
<p>{{ client_name | as_host_object_name }} is part of the Fluid Decomposition Toolkit of the FluCoMa project. For more explanations, learning material, and discussions on its musicianly uses, visit <a href="http://www.flucoma.org/">flucoma.org</a>.</p>
</discussion>
<!--METADATA-->
<metadatalist>
Expand Down
2 changes: 2 additions & 0 deletions flucoma/doc/templates/pd_htmlref.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ <h2>Description</h2>
<h2>Discussion</h2>

{{ discussion|rst }}

<p>Read more about {{ client_name | as_host_object_name }} on the <a href='{{ learn_url | e }}'>learn platform</a>.</p>

<p>{{ client_name | as_host_object_name }} is part of the Fluid Decomposition Toolkit of the FluCoMa project. For more explanations, learning material, and discussions on its musicianly uses, visit <a href="http://www.flucoma.org/">flucoma.org</a>.</p>
</section>
Expand Down
2 changes: 2 additions & 0 deletions flucoma/doc/templates/schelp_base.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ DESCRIPTION::

{{ discussion | rst | indent(first=True) }}

Read more about {{ client_name | as_host_object_name }} on the link::{{learn_url}}##learn platform::.

{% block classmethods %}
CLASSMETHODS::
{% endblock %}
Expand Down
34 changes: 34 additions & 0 deletions flucoma/doc/test/learn_link.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import unittest
from pathlib import Path
from flucoma.doc.learn import derive_learn_link

# A dictionary of client names and what they _should_ become after deriving the learn link
url_map = {
'BufAmpFeature' : 'ampfeature',
'BufNoveltyFeature' : 'noveltyfeature',
'BufOnsetFeature' : 'onsetfeature',
'BufSpectralShape' : 'spectralshape',
'BufChroma' : 'chroma',
'BufLoudness' : 'loudness',
'BufMelbands' : 'melbands',
'BufMFCC' : 'mfcc',
'BufPitch' : 'pitch',
'BufHPSS' : 'hpss',
'BufSines' : 'sines',
'BufTransients' : 'transients',
'BufAmpGate' : 'ampgate',
'BufAmpSlice' : 'ampslice',
'BufNoveltySlice' : 'noveltyslice',
'BufOnsetSlice' : 'onsetslice',
'BufTransientSlice' : 'transientslice',
'BufAudioTransport' : 'audiotransport',
'BufCompose' : 'bufcompose',
'BufNMF' : 'bufnmf',
'BufScale' : 'bufscale',
'BufFlatten' : 'bufflatten'
}

class TestLinkDerivation(unittest.TestCase):
def test_link_derives_correctly(self):
for k, v in url_map.items():
self.assertEqual(derive_learn_link(k), v)
5 changes: 3 additions & 2 deletions flucoma/doc/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
# under the European Union’s Horizon 2020 research and innovation programme
# (grant agreement No 725899).

import copy
import logging
from flucoma.doc.learn import derive_learn_link
from flucoma.doc import logger
from collections import OrderedDict
import copy
from functools import reduce

"""
Expand Down Expand Up @@ -44,8 +45,8 @@ def tidy_split(string,separator=','):
)

def default_transform(object_name, data):

data['client_name'] = object_name
data['learn_url'] = 'https://learn.flucoma.org/reference/' + derive_learn_link(object_name)
data['category'] = []
data['keywords'] = []
data['module'] = 'fluid decomposition'
Expand Down