Repository: pandas-dev/pandas

Issue:
Too many backslashes stripped in documentation generation
I've noticed the generated documentation for [to_csv](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_csv.html) strips backslashes in the newline character

> line_terminator : string, default ‘n’

I thought it was a case of slash stripping, but I checked [the code](https://github.com/pydata/pandas/blob/master/pandas/core/frame.py#L1346) and it's double backslashed there - so the doc generation is a bit aggressive. The [IO doc](http://pandas.pydata.org/pandas-docs/stable/io.html#writing-to-csv-format) is fine, [its code](https://github.com/pydata/pandas/blob/master/doc/source/io.rst) is the same - double backslashed.

Too many backslashes stripped in documentation generation
I've noticed the generated documentation for [to_csv](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_csv.html) strips backslashes in the newline character

> line_terminator : string, default ‘n’

I thought it was a case of slash stripping, but I checked [the code](https://github.com/pydata/pandas/blob/master/pandas/core/frame.py#L1346) and it's double backslashed there - so the doc generation is a bit aggressive. The [IO doc](http://pandas.pydata.org/pandas-docs/stable/io.html#writing-to-csv-format) is fine, [its code](https://github.com/pydata/pandas/blob/master/doc/source/io.rst) is the same - double backslashed.



Discussion:
Thanks for reporting. The `read_csv` docs seem to have the same problem (http://pandas-docs.github.io/pandas-docs-travis/generated/pandas.read_csv.html) for the `sep` and `delim_whitespace` keywords.

Probably easiest solved by making it raw strings of some of them (`r"..."`). Interested in trying to fix this?

I looked into this and made the changes to fix it. Just for reference, it also impacted read_table, as it was tied into the docs with read_csv. 

Thanks for reporting. The `read_csv` docs seem to have the same problem (http://pandas-docs.github.io/pandas-docs-travis/generated/pandas.read_csv.html) for the `sep` and `delim_whitespace` keywords.

Probably easiest solved by making it raw strings of some of them (`r"..."`). Interested in trying to fix this?

I looked into this and made the changes to fix it. Just for reference, it also impacted read_table, as it was tied into the docs with read_csv. 


Resolving patch:
diff --git a/pandas/core/frame.py b/pandas/core/frame.py
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -1306,7 +1306,7 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
                quotechar='"', line_terminator='\n', chunksize=None,
                tupleize_cols=False, date_format=None, doublequote=True,
                escapechar=None, decimal='.', **kwds):
-        """Write DataFrame to a comma-separated values (csv) file
+        r"""Write DataFrame to a comma-separated values (csv) file
 
         Parameters
         ----------
@@ -1343,7 +1343,7 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
             a string representing the compression to use in the output file,
             allowed values are 'gzip', 'bz2', 'xz',
             only used when the first argument is a filename
-        line_terminator : string, default '\\n'
+        line_terminator : string, default ``'\n'``
             The newline character or character sequence to use in the output
             file
         quoting : optional constant from csv module
diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py
--- a/pandas/io/parsers.py
+++ b/pandas/io/parsers.py
@@ -277,11 +277,11 @@
     Parser engine to use. The C engine is faster while the python engine is
     currently more feature-complete."""
 
-_sep_doc = """sep : str, default {default}
+_sep_doc = r"""sep : str, default {default}
     Delimiter to use. If sep is None, will try to automatically determine
-    this. Separators longer than 1 character and different from '\s+' will be
-    interpreted as regular expressions, will force use of the python parsing
-    engine and will ignore quotes in the data. Regex example: '\\r\\t'"""
+    this. Separators longer than 1 character and different from ``'\s+'`` will
+    be interpreted as regular expressions, will force use of the python parsing
+    engine and will ignore quotes in the data. Regex example: ``'\r\t'``"""
 
 _read_csv_doc = """
 Read CSV (comma-separated) file into DataFrame


Test patch: