Skip to content

[SPARK-16294][SQL] Labelling support for the include_example Jekyll plugin #13972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

liancheng
Copy link
Contributor

@liancheng liancheng commented Jun 29, 2016

What changes were proposed in this pull request?

This PR adds labelling support for the include_example Jekyll plugin, so that we may split a single source file into multiple line blocks with different labels, and include them in multiple code snippets in the generated HTML page.

How was this patch tested?

Manually tested.

screenshot at jun 29 19-53-21

@liancheng
Copy link
Contributor Author

@mengxr Could you please help review this PR? Thanks!

@liancheng
Copy link
Contributor Author

Also cc @yhuai and @rxin.

The background here is that I'm going to extract snippets from actual Scala/Java/Python/R source files rather than hard-code them in the SQL programming guide, so that they are easier to maintain.

@SparkQA
Copy link

SparkQA commented Jun 29, 2016

Test build #61467 has finished for PR 13972 at commit 93f3398.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@liancheng
Copy link
Contributor Author

@yinxusen Could you please help review this one since you're the original author of this plugin?

@yinxusen
Copy link
Contributor

I'll take a look.

@yinxusen
Copy link
Contributor

One small matter is that we can't use intersecting labels, e.g.

// $example on:init_session$
some code
// $example on:build_session$
some code
// $example off:init_session$
// $example off:build_session$

But this is a rare case I think. Otherwise LGTM.

@liancheng
Copy link
Contributor Author

liancheng commented Jun 30, 2016

@yinxusen Thanks for the review! Also discussed with @mengxr. IIUC, overlapped labels are most useful for handling imports, since sometimes we may want to include one import line in multiple example snippet blocks. Regarding to this issue, I have two concerns:

  1. It's a rare case, and we possibly can workaround this case while authoring documentations. Thus I guess we can do it in a follow-up PR.

  2. Instead of overlapped labels, I'd prefer a multi-label approach:

    // $example on:A$
    import org.examples.A
    // $example off:A$
    // $example on:A:B$
    import org.examples.common._
    // $example off:A:B$
    // $example on:B$
    import org.examples.B
    // $example off:B$

    This approach achieves the same goal, and is much simpler to implement than handling overlapped scoping.

@liancheng
Copy link
Contributor Author

liancheng commented Jun 30, 2016

@yinxusen @mengxr Actually I found that implementing overlapped labelling is far more easier than I expected earlier... So did it in the last commit.

Made the following experiment to illustrate the effect:

# $SPARK_HOME/examples/src/main/python/test.py

# $example on:foo$
import used.by.foo
# $example on:bar$
import common.stuff
# $example off:foo$
import used.by.bar
# $example off:bar$

Liquid template:

{% include_example foo python/test.py %}

{% include_example bar python/test.py %}

Screenshot:

overlapped-labels

@yinxusen
Copy link
Contributor

LGTM

@liancheng
Copy link
Contributor Author

@yinxusen Thanks!

@yinxusen
Copy link
Contributor

@mengxr With this PR merged, I think we can also fix the SPARK-13015 (mllib-data-types.md ) with a consolidated example file.

@SparkQA
Copy link

SparkQA commented Jun 30, 2016

Test build #61519 has finished for PR 13972 at commit 7ea9c75.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

asfgit pushed a commit that referenced this pull request Jun 30, 2016
…lugin

## What changes were proposed in this pull request?

This PR adds labelling support for the `include_example` Jekyll plugin, so that we may split a single source file into multiple line blocks with different labels, and include them in multiple code snippets in the generated HTML page.

## How was this patch tested?

Manually tested.

<img width="923" alt="screenshot at jun 29 19-53-21" src="https://cloud.githubusercontent.com/assets/230655/16451099/66a76db2-3e33-11e6-84fb-63104c2f0688.png">

Author: Cheng Lian <lian@databricks.com>

Closes #13972 from liancheng/include-example-with-labels.

(cherry picked from commit bde1d6a)
Signed-off-by: Xiangrui Meng <meng@databricks.com>
@mengxr
Copy link
Contributor

mengxr commented Jun 30, 2016

LGTM2. Merged into master and branch-2.0. Thanks!

@mengxr
Copy link
Contributor

mengxr commented Jun 30, 2016

@yinxusen Do you have time to consolidate example files for mllib-data-types.md?

@asfgit asfgit closed this in bde1d6a Jun 30, 2016
@liancheng
Copy link
Contributor Author

Thanks for the review!

@liancheng liancheng deleted the include-example-with-labels branch June 30, 2016 06:34
@liancheng
Copy link
Contributor Author

Other example snippets in the SQL programming guide will be updated in follow-up PRs.

@yinxusen
Copy link
Contributor

@mengxr Sure

asfgit pushed a commit that referenced this pull request Jul 11, 2016
## What changes were proposed in this pull request?
* Update SparkR ML section to make them consistent with SparkR API docs.
* Since #13972 adds labelling support for the ```include_example``` Jekyll plugin, so that we can split the single ```ml.R``` example file into multiple line blocks with different labels, and include them in different algorithms/models in the generated HTML page.

## How was this patch tested?
Only docs update, manually check the generated docs.

Author: Yanbo Liang <ybliang8@gmail.com>

Closes #14011 from yanboliang/r-user-guide-update.

(cherry picked from commit 2ad031b)
Signed-off-by: Shivaram Venkataraman <shivaram@cs.berkeley.edu>
asfgit pushed a commit that referenced this pull request Jul 11, 2016
## What changes were proposed in this pull request?
* Update SparkR ML section to make them consistent with SparkR API docs.
* Since #13972 adds labelling support for the ```include_example``` Jekyll plugin, so that we can split the single ```ml.R``` example file into multiple line blocks with different labels, and include them in different algorithms/models in the generated HTML page.

## How was this patch tested?
Only docs update, manually check the generated docs.

Author: Yanbo Liang <ybliang8@gmail.com>

Closes #14011 from yanboliang/r-user-guide-update.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants