diff --git a/flucoma/doc/learn.py b/flucoma/doc/learn.py
new file mode 100644
index 0000000..84760c7
--- /dev/null
+++ b/flucoma/doc/learn.py
@@ -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()
\ No newline at end of file
diff --git a/flucoma/doc/sc/driver.py b/flucoma/doc/sc/driver.py
index e1ad674..c3ade7f 100644
--- a/flucoma/doc/sc/driver.py
+++ b/flucoma/doc/sc/driver.py
@@ -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
@@ -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'] = ''
diff --git a/flucoma/doc/templates/cli_htmlref.html b/flucoma/doc/templates/cli_htmlref.html
index 8932535..bf20f44 100644
--- a/flucoma/doc/templates/cli_htmlref.html
+++ b/flucoma/doc/templates/cli_htmlref.html
@@ -35,6 +35,7 @@
Description
Discussion
{{ discussion|rst }}
+ Read more about {{ client_name | as_host_object_name }} on the learn platform.
{{ 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 flucoma.org.
diff --git a/flucoma/doc/templates/maxref.xml b/flucoma/doc/templates/maxref.xml
index f6e3410..48774a7 100644
--- a/flucoma/doc/templates/maxref.xml
+++ b/flucoma/doc/templates/maxref.xml
@@ -14,10 +14,10 @@ under the European Union’s Horizon 2020 research and innovation programme
{{ digest }}
{{ description | striprst }}
- Open the Overview Patch
- {{ 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 flucoma.org.
+ Open the Overview Patch
+ {{ discussion | rst | indent(8, first=True)}}
+ Read more about {{ client_name | as_host_object_name }} on the learn platform.
+ {{ 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 flucoma.org.
diff --git a/flucoma/doc/templates/pd_htmlref.html b/flucoma/doc/templates/pd_htmlref.html
index 10ca662..2debc4a 100644
--- a/flucoma/doc/templates/pd_htmlref.html
+++ b/flucoma/doc/templates/pd_htmlref.html
@@ -33,6 +33,8 @@ Description
Discussion
{{ discussion|rst }}
+
+ Read more about {{ client_name | as_host_object_name }} on the learn platform.
{{ 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 flucoma.org.
diff --git a/flucoma/doc/templates/schelp_base.schelp b/flucoma/doc/templates/schelp_base.schelp
index 261858a..a38dc02 100644
--- a/flucoma/doc/templates/schelp_base.schelp
+++ b/flucoma/doc/templates/schelp_base.schelp
@@ -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 %}
diff --git a/flucoma/doc/test/learn_link.py b/flucoma/doc/test/learn_link.py
new file mode 100644
index 0000000..b2456cb
--- /dev/null
+++ b/flucoma/doc/test/learn_link.py
@@ -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)
\ No newline at end of file
diff --git a/flucoma/doc/transformers.py b/flucoma/doc/transformers.py
index 751c07b..392845d 100644
--- a/flucoma/doc/transformers.py
+++ b/flucoma/doc/transformers.py
@@ -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
"""
@@ -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'