-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
## import parsecsv | ||
## import os | ||
## import os, parsecsv | ||
## | ||
## # Prepare a file | ||
## let content = """One,Two,Three,Four | ||
## 1,2,3,4 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Updated documentation for parsecsv module.
ref #10330