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

parsecsv: Updated documentation (#10330) #10391

Merged
merged 11 commits into from
Jan 24, 2019
Merged

parsecsv: Updated documentation (#10330) #10391

merged 11 commits into from
Jan 24, 2019

Conversation

jiro4989
Copy link
Contributor

@jiro4989 jiro4989 commented Jan 20, 2019

Updated documentation for parsecsv module.

  • See also links
  • Runnable examples

ref #10330

@narimiran narimiran self-assigned this Jan 20, 2019
lib/pure/parsecsv.nim Outdated Show resolved Hide resolved
## import parsecsv
## import os
## import os, parsecsv
##
## # Prepare a file
## let content = """One,Two,Three,Four
## 1,2,3,4
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice if the example would also show (a part of) the output, so it is more clear what does it do.

So for this example, that would be:

new row: 
##One:1##
##Two:2##
##Three:3##
##Four:4##
new row: 
##One:10##
...

But I would change ## to something else (or nothing at all: echo col, ": ", p.rowEntry(col)), so that you don't have to write the output in the documentation like ## # ##One:1##, but just: ## # One: 1

Copy link
Member

Choose a reason for hiding this comment

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

I cannot comment on the line 59, as you didn't change it so I'm doing it here:

Make the first letter of the sentence an uppercase. Also try to think if you can describe CsvParser in a bit more detail (maybe put the descriptions for row and headers as a part of CsvParser documentation. Something like this:

type
  CsvRow* = seq[string] ## A row in a CSV file.
  CsvParser* = object of BaseLexer ## The parser object.
    ##
    ## It consists of two public fields:
    ## * `row` is the current row
    ## * `headers` are the columns that are defined in the csv file
    ##   (read using `readHeaderRow <#readHeaderRow,CsvParser>`_).
    ##   Used with `rowEntry <#rowEntry,CsvParser,string>`_).
    row*: CsvRow
    filename: string
    sep, quote, esc: char
    skipWhite: bool
    currRow: int
    headers*: seq[string]
  CsvError* = object of IOError ## An exception that is raised if
                                ## a parsing error occurs.

Copy link
Member

@narimiran narimiran Jan 21, 2019

Choose a reason for hiding this comment

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

Also, on the line 59 (at the end of top-level documentation) I would add "See also" section, linking to similar modules:

(...)
##       echo "##", col, ":", p.rowEntry(col), "##"
##   p.close()
##
##
## See also
## ========
##
## * `parseopt module <#parseopt.html>`_
## * `parsecfg module <#parsecfg.html>`_
## * `parsexml module <#parsexml.html>`_
## * `parsesql module <#parsesql.html>`_

Since streams is frequently used in the examples, it should be linked here too. Maybe some other module too.

lib/pure/parsecsv.nim Outdated Show resolved Hide resolved
lib/pure/parsecsv.nim Show resolved Hide resolved
lib/pure/parsecsv.nim Outdated Show resolved Hide resolved
lib/pure/parsecsv.nim Outdated Show resolved Hide resolved
lib/pure/parsecsv.nim Outdated Show resolved Hide resolved
@narimiran narimiran merged commit bc31eb3 into nim-lang:devel Jan 24, 2019
ThomasTJdev pushed a commit to ThomasTJdev/Nim that referenced this pull request Jan 27, 2019
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.

2 participants