Skip to content
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

[SPARK-19402][DOCS] Support LaTex inline formula correctly and fix warnings in Scala/Java APIs generation #16741

Closed
wants to merge 6 commits into from

Conversation

HyukjinKwon
Copy link
Member

@HyukjinKwon HyukjinKwon commented Jan 30, 2017

What changes were proposed in this pull request?

This PR proposes three things as below:

  • Support LaTex inline-formula, \( ... \) in Scala API documentation
    It seems currently,

    \( ... \)
    

    are rendered as they are, for example,

    2017-01-30 10 01 13

    It seems mistakenly more backslashes were added.

  • Fix warnings Scaladoc/Javadoc generation
    This PR fixes t two types of warnings as below:

    [warn] .../spark/sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala:335: Could not find any member to link for "UnsupportedOperationException".
    [warn]   /**
    [warn]   ^
    
    [warn] .../spark/sql/core/src/main/scala/org/apache/spark/sql/internal/VariableSubstitution.scala:24: Variable var undefined in comment for class VariableSubstitution in class VariableSubstitution
    [warn]  * `${var}`, `${system:var}` and `${env:var}`.
    [warn]      ^
    
  • Fix Javadoc8 break

    [error] .../spark/mllib/target/java/org/apache/spark/ml/PredictionModel.java:7: error: reference not found
    [error]  *                       E.g., {@link VectorUDT} for vector features.
    [error]                                       ^
    [error] .../spark/mllib/target/java/org/apache/spark/ml/PredictorParams.java:12: error: reference not found
    [error]    *                          E.g., {@link VectorUDT} for vector features.
    [error]                                            ^
    [error] .../spark/mllib/target/java/org/apache/spark/ml/Predictor.java:10: error: reference not found
    [error]  *                       E.g., {@link VectorUDT} for vector features.
    [error]                                       ^
    [error] .../spark/sql/hive/target/java/org/apache/spark/sql/hive/HiveAnalysis.java:5: error: reference not found
    [error]  * Note that, this rule must be run after {@link PreprocessTableInsertion}.
    [error]                                                  ^
    

How was this patch tested?

Manually via sbt unidoc and jeykil build.

@HyukjinKwon HyukjinKwon changed the title [WIP][SPARK-19402][DOCS] Support LaTex inline annotation correctly and fix warnings in Scala/Java APIs generation [WIP][SPARK-19402][DOCS] Support LaTex inline formula correctly and fix warnings in Scala/Java APIs generation Jan 30, 2017
Copy link
Member

@srowen srowen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah generally I'm in favor of changing anything that causes a build failure in Java 8, or doesn't render correctly. Otherwise if it just generates a warning, I'm kind of neutral on it, but not against it.

@@ -58,7 +58,7 @@ trait FutureAction[T] extends Future[T] {
*
* @param atMost maximum wait time, which may be negative (no waiting is done), Duration.Inf
* for unbounded waiting, or a finite positive duration
* @throws Exception exception during action execution
* @note Throws `Exception` exception during action execution
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, this still generates warnings in unidoc? Does it actually render correctly anyway?

If it renders correctly, I'm inclined to keep it, as long as it doesn't fail the build.
If it didn't render correctly to begin with, OK.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.. It seems fine although it does not have a link.

  • Scaladoc
    2017-01-30 10 34 38

  • Javadoc
    2017-01-30 10 35 36

Let me revert back those changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Yeah it's unfortunate that this (and other) classes aren't found by unidoc. They're JDK classes! I don't see what we could be doing wrong though,

In other cases it's easy enough to change [[ to a back-tick to work around the warning. Here you'd have to mis-use scaladoc a bit to work around it. I think you could leave this, IMHO. The other [[ changes make sense.

@HyukjinKwon
Copy link
Member Author

HyukjinKwon commented Jan 30, 2017

@srowen, let me just turn this PR to a minor without a JIRA for actual errors here.

Let me consider the warning changes later when I happened to be pretty sure of it, if someone raises this issue again or when any event happens about this .

Uh, I just saw #16741 (comment). Then, should I maybe revert only @note changes here?

@HyukjinKwon
Copy link
Member Author

Actually, I am still neutral on this and confused which way is more correct. It warns anyhow but IMHO changing [[ to back-ticks which are super strictly a little bit worse because [[ at least have some links in Scaladoc.

@HyukjinKwon
Copy link
Member Author

I mean.. it'd be surely better to change it to back-ticks if this breaks but it just warns.. (It is funny that I am saying my proposal should be fixed though). Let me follow your lead please.

@HyukjinKwon
Copy link
Member Author

Oh, wait.... it seems case-by-case. Let me leave some before-after image with some explanation soon.

@SparkQA
Copy link

SparkQA commented Jan 30, 2017

Test build #72152 has finished for PR 16741 at commit 0880b9b.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@@ -262,7 +262,7 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging with Seria
/**
* Get a time parameter as seconds; throws a NoSuchElementException if it's not set. If no
* suffix is provided then seconds are assumed.
* @throws java.util.NoSuchElementException
* @throws java.util.NoSuchElementException If the time parameter is not set
Copy link
Member Author

@HyukjinKwon HyukjinKwon Jan 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before

  • Scaladoc
    2017-01-31 12 24 09

  • Javadoc
    2017-01-31 12 01 57

After

  • Scaladoc
    2017-01-31 12 22 58

  • Javadoc
    2017-01-31 12 23 31

Copy link
Member Author

@HyukjinKwon HyukjinKwon Jan 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And.. here is my observation so far.

Notation Scaladoc Javadoc Link Error/Warn etc.
`DataFrame` Renders OK Renders OK X X
[[DataFrame]] Renders OK Renders OK Scaladoc only Error in javadoc8 Fixed in #16013
@throws IllegalArgumentException ... Renders OK Renders OK X Warn
@throws java.util.NoSuchElementException ... Renders OK Renders OK X Warn
@throws java.util.NoSuchElementException [NO DESCRIPTION] X Renders OK X Warn Fixed here

@@ -78,7 +78,7 @@ abstract class Gradient extends Serializable {
*
* for K classes multiclass classification problem.
*
* The model weights $w = (w_1, w_2, ..., w_{K-1})^T$ becomes a matrix which has dimension of
* The model weights \(w = (w_1, w_2, ..., w_{K-1})^T\) becomes a matrix which has dimension of
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2017-01-31 12 28 42

* $margins_i = x w_i$.
* where $\alpha(i) = 1$ if \(i \ne 0\), and
* $\alpha(i) = 0$ if \(i == 0\),
* \(margins_i = x w_i\).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2017-01-31 12 29 18

* where $\delta_{i, j} = 1$ if $i == j$,
* $\delta_{i, j} = 0$ if $i != j$, and
* where $\delta_{i, j} = 1$ if \(i == j\),
* $\delta_{i, j} = 0$ if \(i != j\), and
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2017-01-31 12 29 02

@HyukjinKwon HyukjinKwon changed the title [WIP][SPARK-19402][DOCS] Support LaTex inline formula correctly and fix warnings in Scala/Java APIs generation [SPARK-19402][DOCS] Support LaTex inline formula correctly and fix warnings in Scala/Java APIs generation Jan 30, 2017
@SparkQA
Copy link

SparkQA commented Jan 30, 2017

Test build #72156 has finished for PR 16741 at commit 7e6e521.

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

@SparkQA
Copy link

SparkQA commented Jan 30, 2017

Test build #72157 has finished for PR 16741 at commit 90bf25b.

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

@srowen
Copy link
Member

srowen commented Feb 1, 2017

merged to master

@asfgit asfgit closed this in f1a1f26 Feb 1, 2017
@HyukjinKwon
Copy link
Member Author

Thank you @srowen!

@jkbradley
Copy link
Member

Thanks for these many cleanups! It's a shame to lose links. Do you think we should use fully qualified names rather than abandoning the links?

@srowen
Copy link
Member

srowen commented Feb 7, 2017

I don't think it's a matter of fully-qualified names; it knows what the type is just thinks it can't find it for some reason and raises a warning/error.

@HyukjinKwon
Copy link
Member Author

Yes, it can't find. I trieid several possible combinations such as fully qualified name, [[ .. ]] and scala specific notations but I had no luck.

@@ -135,13 +135,13 @@ abstract class MLWriter extends BaseReadWrite with Logging {
}

/**
* Trait for classes that provide [[MLWriter]].
* Trait for classes that provide `MLWriter`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HyukjinKwon Are you sure this is a problem? I just tried generating the docs using Java 8, and the link with [[MLWriter]] worked for both Scala and Java. Maybe it is fine for some cases (like this, where MLWriter is part of the package being compiled) and not for other cases (such as when the class is from a dependency).

Copy link
Member Author

@HyukjinKwon HyukjinKwon Feb 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. That's weird. At least, it should warn because I copied and pasted each class names from the messages and went to the file said in the message. Let me double check and be back. Maybe, I made mistakes for few.

Copy link
Member Author

@HyukjinKwon HyukjinKwon Feb 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkbradley, I see. This one seems fine for both.

I think I changed them given def write: MLWriter below...

[warn] .../spark/mllib/src/main/scala/org/apache/spark/ml/util/ReadWrite.scala:143: Could not find any member to link for "MLWriter".
[warn]   /**
[warn]   ^

and I think I swept them here as they looked identical. I am okay to revive identified ones back.

My (maybe nitpicking) concern is, we should be able to identify the cases explicitly and what to do in each case which I guess I and many guys failed to do so. Otherwise, I think we should prefer backquotes in such cases because even if reviving links might work for now for some cases, we could easily introduce other breaks again when we change the codes.

cmonkey pushed a commit to cmonkey/spark that referenced this pull request Feb 15, 2017
…rnings in Scala/Java APIs generation

## What changes were proposed in this pull request?

This PR proposes three things as below:

- Support LaTex inline-formula, `\( ... \)` in Scala API documentation
  It seems currently,

  ```
  \( ... \)
  ```

  are rendered as they are, for example,

  <img width="345" alt="2017-01-30 10 01 13" src="https://cloud.githubusercontent.com/assets/6477701/22423960/ab37d54a-e737-11e6-9196-4f6229c0189c.png">

  It seems mistakenly more backslashes were added.

- Fix warnings Scaladoc/Javadoc generation
  This PR fixes t two types of warnings as below:

  ```
  [warn] .../spark/sql/catalyst/src/main/scala/org/apache/spark/sql/Row.scala:335: Could not find any member to link for "UnsupportedOperationException".
  [warn]   /**
  [warn]   ^
  ```

  ```
  [warn] .../spark/sql/core/src/main/scala/org/apache/spark/sql/internal/VariableSubstitution.scala:24: Variable var undefined in comment for class VariableSubstitution in class VariableSubstitution
  [warn]  * `${var}`, `${system:var}` and `${env:var}`.
  [warn]      ^
  ```

- Fix Javadoc8 break
  ```
  [error] .../spark/mllib/target/java/org/apache/spark/ml/PredictionModel.java:7: error: reference not found
  [error]  *                       E.g., {link VectorUDT} for vector features.
  [error]                                       ^
  [error] .../spark/mllib/target/java/org/apache/spark/ml/PredictorParams.java:12: error: reference not found
  [error]    *                          E.g., {link VectorUDT} for vector features.
  [error]                                            ^
  [error] .../spark/mllib/target/java/org/apache/spark/ml/Predictor.java:10: error: reference not found
  [error]  *                       E.g., {link VectorUDT} for vector features.
  [error]                                       ^
  [error] .../spark/sql/hive/target/java/org/apache/spark/sql/hive/HiveAnalysis.java:5: error: reference not found
  [error]  * Note that, this rule must be run after {link PreprocessTableInsertion}.
  [error]                                                  ^
  ```

## How was this patch tested?

Manually via `sbt unidoc` and `jeykil build`.

Author: hyukjinkwon <[email protected]>

Closes apache#16741 from HyukjinKwon/warn-and-break.
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