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

Update document to latest format #3621

Merged
merged 10 commits into from
Nov 7, 2018
Merged

Conversation

kemchenj
Copy link
Contributor

@kemchenj kemchenj commented Sep 4, 2018

Issue Link 🔗

Some of the document format were outdated and inconsistent. It leads to some weird compile warning like this:

⚠️  *********/Build/Products/Release-iphoneos/Charts/Charts.framework/Headers/
Charts-Swift.h:3208:12: parameter 'stackIndex' not found in the function declaration [-Wdocumentation]

/// \param stackIndex references which value of a stacked-bar entry has been selected

So I think is time to update the document format.

Goals ⚽

Update all the existing document to latest format.

  • Sort section title in order [Summary, Note, Parameters, Throws, Returns]

    before:

    /// Returns: A new value
    /// Note: Some import thing
    /// Throws: MoyaError
    /// Parameters:
    ///   - foo: A Int Value
    ///   - bar: A Double Value

    after:

    /// Note: Some import thing
    /// Parameters:
    ///   - foo: A Int value
    ///   - bar: A Double Value
    /// Throws: MoyaError
    /// Returns: A new value
  • Uppercased the section title

    • /// - note: -> /// - Note:
    • /// - parameter: -> /// - Parameters:
    • /// - returns: -> /// - Returns:
    • /// - throws: -> /// - Throws:
  • Update parameters section format

    before:

    /// parameter foo: A Int value
    /// parameter bar: A Double value

    after:

    /// Parameters:
    ///   - foo: A Int value
    ///   - bar: A Double value
  • Move property's Returns section content to Summary

    before:

    /// - Returns: Some property
    var property: Int

    after:

    /// Some property
    var property: Int
  • Add empty line between summary and other section:

    before:

    /// Function description
    /// Parameters:
    ///   - a: Some Int value
    func foo(a: Int) { ... }

    after:

    /// Function description
    ///
    /// Parameters:
    ///   - a: Some Int value
    func foo(a: Int) { ... }

Implementation Details 🚧

  • Add missing -.

    • Regex: /// (note|return|parameters|throws):
    • Replacement: /// - $1:
  • Remove property's Returns section.

    • Regex: /// - returns: (.+\s+((override|@IBOutlet|@objc|weak|unowned|lazy|static|class|open|public|private|fileprivate|internal)(\(set\))? )*(var|let))
    • Replacement: /// $1
  • Update Parameters section format.

    1. Add Parameters section.
      • Regex: (\n[ ]+)(((/// - parameter \w+:.*\s+)(///((\s+)|( \s+.+\s+)))?)*/// - parameter \w+:.*)
      • Replacement: $1/// - Parameters:$1$2
    2. Remove all parameter prefix.
      • Regex: /// - parameter (\w+):(.*)(\s+///(\n))*(\s+)
      • Replacement: /// - $1:$2$4$5

    Some edge case:

    • Charts/Source/Charts/Components/LegendEntry.swift

      /// - parameter label:                  The legend entry text.
      ///                                     A `nil` label will start a group.
      /// - parameter form:                   The form to draw for this entry.
    • Charts/Source/Charts/Formatters/IValueFormatter.swift

      /// - parameter value:           The value to be formatted
      ///
      /// - parameter dataSetIndex:    The index of the DataSet the entry in focus belongs to
      ///
      /// - parameter viewPortHandler: provides information about the current chart state (scale, translation, ...)
  • Sort sections and add empty line between Summary and other sections.

    • Regex: ((///)[ ]+[^-\n]+(\s+))?(((((/// - Parameters:\s+(/// (( - \w+:)|([^-]{1})).*\s+)+)\s+)|(/// - Returns:.*\s+(/// [^-]{1}.*\s+)*)|(/// - Note:.*\s+(/// [^-]{1}.*\s+)*)|(/// - Throws:.*\s+(/// [^-]{1}.*\s+)*))(///\n\s+)?)+)
      • Regex to match last line of summary section:
        ///[ ]+[^-\n]+\s+?
        
      • Regex to match parameters section:
        /// - Parameters:\s+
        (/// ((  - \w+:)|([^-]{1})).*\s+)+
        
      • Regex to match other section:
        /// - (Returns|Throws|Note):.*\s+
        (/// [^-]{1}.*\s+)*
        
      • Regex to match empty comment line between sections:
        ///\n\s+?
        
    • Replacement: $1$2$3$15$7$17$13
      • $1: Last non-empty line of summary section
      • $2: ///
      • $3: New lines and white spaces, use this one and $2 to add empty line between summary and other sections
      • $15: Note section
      • $7: Parameters section
      • $17: Throws section
      • $13: Returns section
  • Uppercased the section title(regex)

  • Remove duplicated section(manually)

  • Fix a document error(manually)

Testing Details 🔍

N/A

@codecov-io
Copy link

codecov-io commented Sep 4, 2018

Codecov Report

Merging #3621 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3621   +/-   ##
=======================================
  Coverage   31.01%   31.01%           
=======================================
  Files         114      114           
  Lines       10482    10482           
=======================================
  Hits         3251     3251           
  Misses       7231     7231
Impacted Files Coverage Δ
...ta/Implementations/Standard/ScatterChartData.swift 0% <ø> (ø) ⬆️
Source/Charts/Charts/BarChartView.swift 32.5% <ø> (ø) ⬆️
Source/Charts/Charts/CombinedChartView.swift 25% <ø> (ø) ⬆️
Source/Charts/Utils/Platform+Accessibility.swift 31.57% <ø> (ø) ⬆️
Source/Charts/Charts/PieRadarChartViewBase.swift 5.63% <ø> (ø) ⬆️
...mplementations/Standard/CandleChartDataEntry.swift 0% <ø> (ø) ⬆️
Source/Charts/Charts/HorizontalBarChartView.swift 0% <ø> (ø) ⬆️
Source/Charts/Charts/ChartViewBase.swift 19.51% <ø> (ø) ⬆️
...ource/Charts/Renderers/ChartDataRendererBase.swift 54.54% <ø> (ø) ⬆️
Source/Charts/Animation/Animator.swift 1.61% <ø> (ø) ⬆️
... and 37 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55028b1...a435669. Read the comment docs.

@liuxuan30
Copy link
Member

liuxuan30 commented Sep 19, 2018

How did you make this change, manually or by some tools? I cannot trust my eyes reviewing this.. though I tend to be green light to merge

@kemchenj kemchenj force-pushed the master branch 2 times, most recently from dcaf093 to 6de6a78 Compare September 21, 2018 09:27
```
(\n[ ]+)(((/// - parameter \w+:.*\s+)(///((\s+)|( \s+.+\s+)))?)*/// - parameter \w+:.*)
```

```
$1/// - Parameters:$1$2
```
```
/// - parameter (\w+):(.*)(\s+///(\n))*(\s+)
```

```
///   - $1:$2$4$5
```
```
/// - returns: (.+\s+((override|@IBOutlet|@objc|weak|unowned|lazy|static|class|open|public|private|fileprivate|internal)(\(set\))? )*(var|let))
```

```
/// $1
```
```
/// (note|return|parameters|throws):
```

```
/// - $1:
```
@kemchenj
Copy link
Contributor Author

kemchenj commented Sep 22, 2018

@liuxuan30 Basically regex + manually.

I've add some details in the initial comment, include the format guideline and regex that I used.

And I split the changes into separate commits, describe the regex in commit message. I think that would be useful for you guys to review.

screen shot 2018-09-23 at 00 51 33

```
((///)[ ]+[^-\n]+(\s+))?(((((/// - Parameters:\s+(/// (( - \w+:)|([^-]{1})).*\s+)+)\s+)|(/// - Returns:.*\s+(/// [^-]{1}.*\s+)*)|(/// - Note:.*\s+(/// [^-]{1}.*\s+)*)|(/// - Throws:.*\s+(/// [^-]{1}.*\s+)*))(///\n\s+)?)+)
```

```
$1$2$3$15$7$17$13
```
Source/Charts/Charts/BarChartView.swift Show resolved Hide resolved
Source/Charts/Charts/ChartViewBase.swift Show resolved Hide resolved
@@ -742,46 +775,47 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate
}

/// *
/// - note: (Equivalent of getCenter() in MPAndroidChart, as center is already a standard in iOS that returns the center point relative to superview, and MPAndroidChart returns relative to self)*
/// - returns: The center point of the chart (the whole View) in pixels.
///
Copy link
Member

Choose a reason for hiding this comment

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

why we need a /// here?

Copy link
Member

Choose a reason for hiding this comment

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

@kemchenj is this one ok to resolve without any change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already removed.

@@ -55,8 +55,9 @@ open class ChartDataSet: ChartBaseDataSet
// MARK: - Data functions and accessors

/// *
/// - note: Calls `notifyDataSetChanged()` after setting a new value.
/// - returns: The array of y-values that this DataSet represents.
///
Copy link
Member

Choose a reason for hiding this comment

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

do we need /// here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I regard * as part of "Summary" section. And I am not really sure what it means, maybe it is some magic sign here for someone. So I just leave it here.😂

Copy link
Member

Choose a reason for hiding this comment

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

@jjatie any idea? If it's ok, it seems this PR can be merged now.

Copy link
Collaborator

@jjatie jjatie Oct 27, 2018

Choose a reason for hiding this comment

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

The * and the empty /// can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I just push a new commit to remove them.

@liuxuan30
Copy link
Member

@kemchenj please check above comments. I found some inconsistence of /// usage. I tried to mark every one I found, but please have a double check if I missed some.

@kemchenj
Copy link
Contributor Author

@liuxuan30 Sorry for late reply. I could not find a proper regex for those inconsistent separator line behavior these days. So I just fixed it manually and I got a double check. Please review it again.

@liuxuan30
Copy link
Member

do you forecast there would be more fixes for this PR? Otherwise we could get merged soon

@kemchenj
Copy link
Contributor Author

kemchenj commented Nov 4, 2018

Nope, I think it won't be more fixes for this PR.

@liuxuan30 liuxuan30 merged commit ce0d809 into ChartsOrg:master Nov 7, 2018
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