beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From al...@apache.org
Subject [beam] branch master updated: [BEAM-7389] Update include buttons to support multiple languages
Date Fri, 04 Oct 2019 17:05:33 GMT
This is an automated email from the ASF dual-hosted git repository.

altay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 69bfdac  [BEAM-7389] Update include buttons to support multiple languages
     new 8e75935  Merge pull request #9669 from davidcavazos/include-buttons
69bfdac is described below

commit 69bfdacb94e1d8b25359115341f68ab309f4ff6f
Author: David Cavazos <dcavazos@google.com>
AuthorDate: Thu Sep 26 11:48:31 2019 -0700

    [BEAM-7389] Update include buttons to support multiple languages
---
 website/notebooks/generate.py                      |  1 +
 website/src/_includes/button.md                    |  4 +--
 website/src/_includes/buttons-code-snippet.md      | 35 +++++++++++++--------
 .../transforms/python/element-wise/filter.md       | 24 +++++++--------
 .../transforms/python/element-wise/flatmap.md      | 36 +++++++++++-----------
 5 files changed, 56 insertions(+), 44 deletions(-)

diff --git a/website/notebooks/generate.py b/website/notebooks/generate.py
index 76e69a7..a648e2c 100644
--- a/website/notebooks/generate.py
+++ b/website/notebooks/generate.py
@@ -67,6 +67,7 @@ def run(docs, variables=None,
             imports=imports,
             notebook_title=doc.get('title', os.path.basename(basename).replace('-', ' ')),
             keep_classes=['language-' + lang, 'shell-sh'],
+            filter_classes='notebook-skip',
             docs_url='https://beam.apache.org/' + basename.replace('-', ''),
             docs_logo_url=docs_logo_url,
             github_ipynb_url='https://github.com/apache/beam/blob/master/' + ipynb_file,
diff --git a/website/src/_includes/button.md b/website/src/_includes/button.md
index 0413771..de7a414 100644
--- a/website/src/_includes/button.md
+++ b/website/src/_includes/button.md
@@ -12,10 +12,10 @@ See the License for the specific language governing permissions and
 limitations under the License.
 -->
 
-<div>
+{% if include.attrib %}
+{:{{ include.attrib }}}{% endif %}
 <table align="left" style="margin-right:1em">
   <td>
     <a class="button" target="_blank" href="{{ include.url }}">{% if include.logo %}<img
src="{{ include.logo }}" width="32px" height="32px" alt="{{ include.text }}" /> {% endif
%}{{ include.text }}</a>
   </td>
 </table>
-</div>
diff --git a/website/src/_includes/buttons-code-snippet.md b/website/src/_includes/buttons-code-snippet.md
index 055a730..54ac914 100644
--- a/website/src/_includes/buttons-code-snippet.md
+++ b/website/src/_includes/buttons-code-snippet.md
@@ -12,21 +12,32 @@ See the License for the specific language governing permissions and
 limitations under the License.
 -->
 
+{% capture colab_logo %}https://github.com/googlecolab/open_in_colab/raw/master/images/icon32.png{%
endcapture %}
+{% capture github_logo %}https://www.tensorflow.org/images/GitHub-Mark-32px.png{% endcapture
%}
+
 {% capture notebook_url %}https://colab.research.google.com/github/{{ site.branch_repo }}/{{
include.notebook }}{% endcapture %}
+{% capture notebook_java %}{{ notebook_url }}-java.ipynb{% endcapture %}
+{% capture notebook_py %}{{ notebook_url }}-py.ipynb{% endcapture %}
+{% capture notebook_go %}{{ notebook_url }}-go.ipynb{% endcapture %}
+
+{% capture code_url %}https://github.com/{{ site.branch_repo }}{% endcapture %}
+{% capture code_java %}{{ code_url }}/{{ include.java }}{% endcapture %}
+{% capture code_py %}{{ code_url }}/{{ include.py }}{% endcapture %}
+{% capture code_go %}{{ code_url }}/{{ include.go }}{% endcapture %}
 
-{% capture code_url %}https://github.com/{{ site.branch_repo }}/{{ include.code }}{% endcapture
%}
+{% if include.java %}
+{% if include.notebook %}{% include button.md url=notebook_java logo=colab_logo text="Run
code now" attrib=".language-java .notebook-skip" %}{% endif %}
+{% include button.md url=code_java logo=github_logo text="View source code" attrib=".language-java"
%}
+{% endif %}
 
-{:.notebook-skip}
-{% include button.md
-  url=notebook_url
-  logo="https://github.com/googlecolab/open_in_colab/raw/master/images/icon32.png"
-  text="Run code now"
-%}
+{% if include.py %}
+{% if include.notebook %}{% include button.md url=notebook_py logo=colab_logo text="Run code
now" attrib=".language-py .notebook-skip" %}{% endif %}
+{% include button.md url=code_py logo=github_logo text="View source code" attrib=".language-py"
%}
+{% endif %}
 
-{% include button.md
-  url=code_url
-  logo="https://www.tensorflow.org/images/GitHub-Mark-32px.png"
-  text="View source code"
-%}
+{% if include.go %}
+{% if include.notebook %}{% include button.md url=notebook_go logo=colab_logo text="Run code
now" attrib=".language-go .notebook-skip" %}{% endif %}
+{% include button.md url=code_go logo=github_logo text="View source code" attrib=".language-go"
%}
+{% endif %}
 
 <br><br><br>
diff --git a/website/src/documentation/transforms/python/element-wise/filter.md b/website/src/documentation/transforms/python/element-wise/filter.md
index 346ffb4..e812cfb 100644
--- a/website/src/documentation/transforms/python/element-wise/filter.md
+++ b/website/src/documentation/transforms/python/element-wise/filter.md
@@ -52,8 +52,8 @@ Output `PCollection` after `Filter`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter_test.py
tag:perennials %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/filter-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/filter"
 %}
 
 ### Example 2: Filtering with a lambda function
@@ -71,8 +71,8 @@ Output `PCollection` after `Filter`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter_test.py
tag:perennials %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/filter-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/filter"
 %}
 
 ### Example 3: Filtering with multiple arguments
@@ -93,8 +93,8 @@ Output `PCollection` after `Filter`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter_test.py
tag:perennials %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/filter-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/filter"
 %}
 
 ### Example 4: Filtering with side inputs as singletons
@@ -116,8 +116,8 @@ Output `PCollection` after `Filter`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter_test.py
tag:perennials %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/filter-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/filter"
 %}
 
 ### Example 5: Filtering with side inputs as iterators
@@ -137,8 +137,8 @@ Output `PCollection` after `Filter`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter_test.py
tag:valid_plants %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/filter-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/filter"
 %}
 
 > **Note**: You can pass the `PCollection` as a *list* with `beam.pvalue.AsList(pcollection)`,
@@ -162,8 +162,8 @@ Output `PCollection` after `Filter`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter_test.py
tag:perennials %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/filter-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/filter.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/filter"
 %}
 
 ## Related transforms
diff --git a/website/src/documentation/transforms/python/element-wise/flatmap.md b/website/src/documentation/transforms/python/element-wise/flatmap.md
index d2e861a..b535127 100644
--- a/website/src/documentation/transforms/python/element-wise/flatmap.md
+++ b/website/src/documentation/transforms/python/element-wise/flatmap.md
@@ -53,8 +53,8 @@ Output `PCollection` after `FlatMap`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map_test.py
tag:plants %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap"
 %}
 
 ### Example 2: FlatMap with a function
@@ -72,8 +72,8 @@ Output `PCollection` after `FlatMap`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map_test.py
tag:plants %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap"
 %}
 
 ### Example 3: FlatMap with a lambda function
@@ -93,8 +93,8 @@ Output `PCollection` after `FlatMap`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map_test.py
tag:plants %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap"
 %}
 
 ### Example 4: FlatMap with a generator
@@ -114,8 +114,8 @@ Output `PCollection` after `FlatMap`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map_test.py
tag:plants %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap"
 %}
 
 ### Example 5: FlatMapTuple for key-value pairs
@@ -134,8 +134,8 @@ Output `PCollection` after `FlatMapTuple`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map_test.py
tag:plants %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap"
 %}
 
 ### Example 6: FlatMap with multiple arguments
@@ -156,8 +156,8 @@ Output `PCollection` after `FlatMap`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map_test.py
tag:plants %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap"
 %}
 
 ### Example 7: FlatMap with side inputs as singletons
@@ -179,8 +179,8 @@ Output `PCollection` after `FlatMap`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map_test.py
tag:plants %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap"
 %}
 
 ### Example 8: FlatMap with side inputs as iterators
@@ -200,8 +200,8 @@ Output `PCollection` after `FlatMap`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map_test.py
tag:valid_plants %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap"
 %}
 
 > **Note**: You can pass the `PCollection` as a *list* with `beam.pvalue.AsList(pcollection)`,
@@ -225,8 +225,8 @@ Output `PCollection` after `FlatMap`:
 {% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map_test.py
tag:valid_plants %}```
 
 {% include buttons-code-snippet.md
-  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap-py.ipynb"
-  code="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  py="sdks/python/apache_beam/examples/snippets/transforms/element_wise/flat_map.py"
+  notebook="examples/notebooks/documentation/transforms/python/element-wise/flatmap"
 %}
 
 ## Related transforms


Mime
View raw message