We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add newlines between options in help text
In case of multi-line help messages for options the list of options ``cmd --help`` gets difficult to read. It would be great to have an option to toggle extra newlines after multi-line help messages / in general between option help messages.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `click/formatting.py`
Content:
```
1 from contextlib import contextmanager
2 from .termui import get_terminal_size
3 from .parser import split_opt
4 from ._compat import term_len
5 
6 
7 # Can force a width.  This is used by the test system
8 FORCED_WIDTH = None
9 
10 
11 def measure_table(rows):
12     widths = {}
13     for row in rows:
14         for idx, col in enumerate(row):
15             widths[idx] = max(widths.get(idx, 0), term_len(col))
16     return tuple(y for x, y in sorted(widths.items()))
17 
18 
19 def iter_rows(rows, col_count):
20     for row in rows:
21         row = tuple(row)
22         yield row + ('',) * (col_count - len(row))
23 
24 
25 def wrap_text(text, width=78, initial_indent='', subsequent_indent='',
26               preserve_paragraphs=False):
27     """A helper function that intelligently wraps text.  By default, it
28     assumes that it operates on a single paragraph of text but if the
29     `preserve_paragraphs` parameter is provided it will intelligently
30     handle paragraphs (defined by two empty lines).
31 
32     If paragraphs are handled, a paragraph can be prefixed with an empty
33     line containing the ``\\b`` character (``\\x08``) to indicate that
34     no rewrapping should happen in that block.
35 
36     :param text: the text that should be rewrapped.
37     :param width: the maximum width for the text.
38     :param initial_indent: the initial indent that should be placed on the
39                            first line as a string.
40     :param subsequent_indent: the indent string that should be placed on
41                               each consecutive line.
42     :param preserve_paragraphs: if this flag is set then the wrapping will
43                                 intelligently handle paragraphs.
44     """
45     from ._textwrap import TextWrapper
46     text = text.expandtabs()
47     wrapper = TextWrapper(width, initial_indent=initial_indent,
48                           subsequent_indent=subsequent_indent,
49                           replace_whitespace=False)
50     if not preserve_paragraphs:
51         return wrapper.fill(text)
52 
53     p = []
54     buf = []
55     indent = None
56 
57     def _flush_par():
58         if not buf:
59             return
60         if buf[0].strip() == '\b':
61             p.append((indent or 0, True, '\n'.join(buf[1:])))
62         else:
63             p.append((indent or 0, False, ' '.join(buf)))
64         del buf[:]
65 
66     for line in text.splitlines():
67         if not line:
68             _flush_par()
69             indent = None
70         else:
71             if indent is None:
72                 orig_len = term_len(line)
73                 line = line.lstrip()
74                 indent = orig_len - term_len(line)
75             buf.append(line)
76     _flush_par()
77 
78     rv = []
79     for indent, raw, text in p:
80         with wrapper.extra_indent(' ' * indent):
81             if raw:
82                 rv.append(wrapper.indent_only(text))
83             else:
84                 rv.append(wrapper.fill(text))
85 
86     return '\n\n'.join(rv)
87 
88 
89 class HelpFormatter(object):
90     """This class helps with formatting text-based help pages.  It's
91     usually just needed for very special internal cases, but it's also
92     exposed so that developers can write their own fancy outputs.
93 
94     At present, it always writes into memory.
95 
96     :param indent_increment: the additional increment for each level.
97     :param width: the width for the text.  This defaults to the terminal
98                   width clamped to a maximum of 78.
99     """
100 
101     def __init__(self, indent_increment=2, width=None, max_width=None):
102         self.indent_increment = indent_increment
103         if max_width is None:
104             max_width = 80
105         if width is None:
106             width = FORCED_WIDTH
107             if width is None:
108                 width = max(min(get_terminal_size()[0], max_width) - 2, 50)
109         self.width = width
110         self.current_indent = 0
111         self.buffer = []
112 
113     def write(self, string):
114         """Writes a unicode string into the internal buffer."""
115         self.buffer.append(string)
116 
117     def indent(self):
118         """Increases the indentation."""
119         self.current_indent += self.indent_increment
120 
121     def dedent(self):
122         """Decreases the indentation."""
123         self.current_indent -= self.indent_increment
124 
125     def write_usage(self, prog, args='', prefix='Usage: '):
126         """Writes a usage line into the buffer.
127 
128         :param prog: the program name.
129         :param args: whitespace separated list of arguments.
130         :param prefix: the prefix for the first line.
131         """
132         usage_prefix = '%*s%s ' % (self.current_indent, prefix, prog)
133         text_width = self.width - self.current_indent
134 
135         if text_width >= (term_len(usage_prefix) + 20):
136             # The arguments will fit to the right of the prefix.
137             indent = ' ' * term_len(usage_prefix)
138             self.write(wrap_text(args, text_width,
139                                  initial_indent=usage_prefix,
140                                  subsequent_indent=indent))
141         else:
142             # The prefix is too long, put the arguments on the next line.
143             self.write(usage_prefix)
144             self.write('\n')
145             indent = ' ' * (max(self.current_indent, term_len(prefix)) + 4)
146             self.write(wrap_text(args, text_width,
147                                  initial_indent=indent,
148                                  subsequent_indent=indent))
149 
150         self.write('\n')
151 
152     def write_heading(self, heading):
153         """Writes a heading into the buffer."""
154         self.write('%*s%s:\n' % (self.current_indent, '', heading))
155 
156     def write_paragraph(self):
157         """Writes a paragraph into the buffer."""
158         if self.buffer:
159             self.write('\n')
160 
161     def write_text(self, text):
162         """Writes re-indented text into the buffer.  This rewraps and
163         preserves paragraphs.
164         """
165         text_width = max(self.width - self.current_indent, 11)
166         indent = ' ' * self.current_indent
167         self.write(wrap_text(text, text_width,
168                              initial_indent=indent,
169                              subsequent_indent=indent,
170                              preserve_paragraphs=True))
171         self.write('\n')
172 
173     def write_dl(self, rows, col_max=30, col_spacing=2):
174         """Writes a definition list into the buffer.  This is how options
175         and commands are usually formatted.
176 
177         :param rows: a list of two item tuples for the terms and values.
178         :param col_max: the maximum width of the first column.
179         :param col_spacing: the number of spaces between the first and
180                             second column.
181         """
182         rows = list(rows)
183         widths = measure_table(rows)
184         if len(widths) != 2:
185             raise TypeError('Expected two columns for definition list')
186 
187         first_col = min(widths[0], col_max) + col_spacing
188 
189         for first, second in iter_rows(rows, len(widths)):
190             self.write('%*s%s' % (self.current_indent, '', first))
191             if not second:
192                 self.write('\n')
193                 continue
194             if term_len(first) <= first_col - col_spacing:
195                 self.write(' ' * (first_col - term_len(first)))
196             else:
197                 self.write('\n')
198                 self.write(' ' * (first_col + self.current_indent))
199 
200             text_width = max(self.width - first_col - 2, 10)
201             wrapped_text = wrap_text(second, text_width, preserve_paragraphs=True)
202             lines = wrapped_text.splitlines()
203 
204             if lines:
205                 self.write(lines[0] + '\n')
206 
207                 for line in lines[1:]:
208                     self.write('%*s%s\n' % (first_col + self.current_indent, '', line))
209             else:
210                 self.write('\n')
211 
212     @contextmanager
213     def section(self, name):
214         """Helpful context manager that writes a paragraph, a heading,
215         and the indents.
216 
217         :param name: the section name that is written as heading.
218         """
219         self.write_paragraph()
220         self.write_heading(name)
221         self.indent()
222         try:
223             yield
224         finally:
225             self.dedent()
226 
227     @contextmanager
228     def indentation(self):
229         """A context manager that increases the indentation."""
230         self.indent()
231         try:
232             yield
233         finally:
234             self.dedent()
235 
236     def getvalue(self):
237         """Returns the buffer contents."""
238         return ''.join(self.buffer)
239 
240 
241 def join_options(options):
242     """Given a list of option strings this joins them in the most appropriate
243     way and returns them in the form ``(formatted_string,
244     any_prefix_is_slash)`` where the second item in the tuple is a flag that
245     indicates if any of the option prefixes was a slash.
246     """
247     rv = []
248     any_prefix_is_slash = False
249     for opt in options:
250         prefix = split_opt(opt)[0]
251         if prefix == '/':
252             any_prefix_is_slash = True
253         rv.append((len(prefix), opt))
254 
255     rv.sort(key=lambda x: x[0])
256 
257     rv = ', '.join(x[1] for x in rv)
258     return rv, any_prefix_is_slash
259
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/click/formatting.py b/click/formatting.py
--- a/click/formatting.py
+++ b/click/formatting.py
@@ -206,6 +206,10 @@
 
                 for line in lines[1:]:
                     self.write('%*s%s\n' % (first_col + self.current_indent, '', line))
+
+                if len(lines) > 1:
+                    # separate long help from next option
+                    self.write("\n")
             else:
                 self.write('\n')

{"golden_diff": "diff --git a/click/formatting.py b/click/formatting.py\n--- a/click/formatting.py\n+++ b/click/formatting.py\n@@ -206,6 +206,10 @@\n \n                 for line in lines[1:]:\n                     self.write('%*s%s\\n' % (first_col + self.current_indent, '', line))\n+\n+                if len(lines) > 1:\n+                    # separate long help from next option\n+                    self.write(\"\\n\")\n             else:\n                 self.write('\\n')\n", "issue": "Add newlines between options in help text\nIn case of multi-line help messages for options the list of options ``cmd --help`` gets difficult to read. It would be great to have an option to toggle extra newlines after multi-line help messages / in general between option help messages.\n", "before_files": [{"content": "from contextlib import contextmanager\nfrom .termui import get_terminal_size\nfrom .parser import split_opt\nfrom ._compat import term_len\n\n\n# Can force a width.  This is used by the test system\nFORCED_WIDTH = None\n\n\ndef measure_table(rows):\n    widths = {}\n    for row in rows:\n        for idx, col in enumerate(row):\n            widths[idx] = max(widths.get(idx, 0), term_len(col))\n    return tuple(y for x, y in sorted(widths.items()))\n\n\ndef iter_rows(rows, col_count):\n    for row in rows:\n        row = tuple(row)\n        yield row + ('',) * (col_count - len(row))\n\n\ndef wrap_text(text, width=78, initial_indent='', subsequent_indent='',\n              preserve_paragraphs=False):\n    \"\"\"A helper function that intelligently wraps text.  By default, it\n    assumes that it operates on a single paragraph of text but if the\n    `preserve_paragraphs` parameter is provided it will intelligently\n    handle paragraphs (defined by two empty lines).\n\n    If paragraphs are handled, a paragraph can be prefixed with an empty\n    line containing the ``\\\\b`` character (``\\\\x08``) to indicate that\n    no rewrapping should happen in that block.\n\n    :param text: the text that should be rewrapped.\n    :param width: the maximum width for the text.\n    :param initial_indent: the initial indent that should be placed on the\n                           first line as a string.\n    :param subsequent_indent: the indent string that should be placed on\n                              each consecutive line.\n    :param preserve_paragraphs: if this flag is set then the wrapping will\n                                intelligently handle paragraphs.\n    \"\"\"\n    from ._textwrap import TextWrapper\n    text = text.expandtabs()\n    wrapper = TextWrapper(width, initial_indent=initial_indent,\n                          subsequent_indent=subsequent_indent,\n                          replace_whitespace=False)\n    if not preserve_paragraphs:\n        return wrapper.fill(text)\n\n    p = []\n    buf = []\n    indent = None\n\n    def _flush_par():\n        if not buf:\n            return\n        if buf[0].strip() == '\\b':\n            p.append((indent or 0, True, '\\n'.join(buf[1:])))\n        else:\n            p.append((indent or 0, False, ' '.join(buf)))\n        del buf[:]\n\n    for line in text.splitlines():\n        if not line:\n            _flush_par()\n            indent = None\n        else:\n            if indent is None:\n                orig_len = term_len(line)\n                line = line.lstrip()\n                indent = orig_len - term_len(line)\n            buf.append(line)\n    _flush_par()\n\n    rv = []\n    for indent, raw, text in p:\n        with wrapper.extra_indent(' ' * indent):\n            if raw:\n                rv.append(wrapper.indent_only(text))\n            else:\n                rv.append(wrapper.fill(text))\n\n    return '\\n\\n'.join(rv)\n\n\nclass HelpFormatter(object):\n    \"\"\"This class helps with formatting text-based help pages.  It's\n    usually just needed for very special internal cases, but it's also\n    exposed so that developers can write their own fancy outputs.\n\n    At present, it always writes into memory.\n\n    :param indent_increment: the additional increment for each level.\n    :param width: the width for the text.  This defaults to the terminal\n                  width clamped to a maximum of 78.\n    \"\"\"\n\n    def __init__(self, indent_increment=2, width=None, max_width=None):\n        self.indent_increment = indent_increment\n        if max_width is None:\n            max_width = 80\n        if width is None:\n            width = FORCED_WIDTH\n            if width is None:\n                width = max(min(get_terminal_size()[0], max_width) - 2, 50)\n        self.width = width\n        self.current_indent = 0\n        self.buffer = []\n\n    def write(self, string):\n        \"\"\"Writes a unicode string into the internal buffer.\"\"\"\n        self.buffer.append(string)\n\n    def indent(self):\n        \"\"\"Increases the indentation.\"\"\"\n        self.current_indent += self.indent_increment\n\n    def dedent(self):\n        \"\"\"Decreases the indentation.\"\"\"\n        self.current_indent -= self.indent_increment\n\n    def write_usage(self, prog, args='', prefix='Usage: '):\n        \"\"\"Writes a usage line into the buffer.\n\n        :param prog: the program name.\n        :param args: whitespace separated list of arguments.\n        :param prefix: the prefix for the first line.\n        \"\"\"\n        usage_prefix = '%*s%s ' % (self.current_indent, prefix, prog)\n        text_width = self.width - self.current_indent\n\n        if text_width >= (term_len(usage_prefix) + 20):\n            # The arguments will fit to the right of the prefix.\n            indent = ' ' * term_len(usage_prefix)\n            self.write(wrap_text(args, text_width,\n                                 initial_indent=usage_prefix,\n                                 subsequent_indent=indent))\n        else:\n            # The prefix is too long, put the arguments on the next line.\n            self.write(usage_prefix)\n            self.write('\\n')\n            indent = ' ' * (max(self.current_indent, term_len(prefix)) + 4)\n            self.write(wrap_text(args, text_width,\n                                 initial_indent=indent,\n                                 subsequent_indent=indent))\n\n        self.write('\\n')\n\n    def write_heading(self, heading):\n        \"\"\"Writes a heading into the buffer.\"\"\"\n        self.write('%*s%s:\\n' % (self.current_indent, '', heading))\n\n    def write_paragraph(self):\n        \"\"\"Writes a paragraph into the buffer.\"\"\"\n        if self.buffer:\n            self.write('\\n')\n\n    def write_text(self, text):\n        \"\"\"Writes re-indented text into the buffer.  This rewraps and\n        preserves paragraphs.\n        \"\"\"\n        text_width = max(self.width - self.current_indent, 11)\n        indent = ' ' * self.current_indent\n        self.write(wrap_text(text, text_width,\n                             initial_indent=indent,\n                             subsequent_indent=indent,\n                             preserve_paragraphs=True))\n        self.write('\\n')\n\n    def write_dl(self, rows, col_max=30, col_spacing=2):\n        \"\"\"Writes a definition list into the buffer.  This is how options\n        and commands are usually formatted.\n\n        :param rows: a list of two item tuples for the terms and values.\n        :param col_max: the maximum width of the first column.\n        :param col_spacing: the number of spaces between the first and\n                            second column.\n        \"\"\"\n        rows = list(rows)\n        widths = measure_table(rows)\n        if len(widths) != 2:\n            raise TypeError('Expected two columns for definition list')\n\n        first_col = min(widths[0], col_max) + col_spacing\n\n        for first, second in iter_rows(rows, len(widths)):\n            self.write('%*s%s' % (self.current_indent, '', first))\n            if not second:\n                self.write('\\n')\n                continue\n            if term_len(first) <= first_col - col_spacing:\n                self.write(' ' * (first_col - term_len(first)))\n            else:\n                self.write('\\n')\n                self.write(' ' * (first_col + self.current_indent))\n\n            text_width = max(self.width - first_col - 2, 10)\n            wrapped_text = wrap_text(second, text_width, preserve_paragraphs=True)\n            lines = wrapped_text.splitlines()\n\n            if lines:\n                self.write(lines[0] + '\\n')\n\n                for line in lines[1:]:\n                    self.write('%*s%s\\n' % (first_col + self.current_indent, '', line))\n            else:\n                self.write('\\n')\n\n    @contextmanager\n    def section(self, name):\n        \"\"\"Helpful context manager that writes a paragraph, a heading,\n        and the indents.\n\n        :param name: the section name that is written as heading.\n        \"\"\"\n        self.write_paragraph()\n        self.write_heading(name)\n        self.indent()\n        try:\n            yield\n        finally:\n            self.dedent()\n\n    @contextmanager\n    def indentation(self):\n        \"\"\"A context manager that increases the indentation.\"\"\"\n        self.indent()\n        try:\n            yield\n        finally:\n            self.dedent()\n\n    def getvalue(self):\n        \"\"\"Returns the buffer contents.\"\"\"\n        return ''.join(self.buffer)\n\n\ndef join_options(options):\n    \"\"\"Given a list of option strings this joins them in the most appropriate\n    way and returns them in the form ``(formatted_string,\n    any_prefix_is_slash)`` where the second item in the tuple is a flag that\n    indicates if any of the option prefixes was a slash.\n    \"\"\"\n    rv = []\n    any_prefix_is_slash = False\n    for opt in options:\n        prefix = split_opt(opt)[0]\n        if prefix == '/':\n            any_prefix_is_slash = True\n        rv.append((len(prefix), opt))\n\n    rv.sort(key=lambda x: x[0])\n\n    rv = ', '.join(x[1] for x in rv)\n    return rv, any_prefix_is_slash\n", "path": "click/formatting.py"}], "after_files": [{"content": "from contextlib import contextmanager\nfrom .termui import get_terminal_size\nfrom .parser import split_opt\nfrom ._compat import term_len\n\n\n# Can force a width.  This is used by the test system\nFORCED_WIDTH = None\n\n\ndef measure_table(rows):\n    widths = {}\n    for row in rows:\n        for idx, col in enumerate(row):\n            widths[idx] = max(widths.get(idx, 0), term_len(col))\n    return tuple(y for x, y in sorted(widths.items()))\n\n\ndef iter_rows(rows, col_count):\n    for row in rows:\n        row = tuple(row)\n        yield row + ('',) * (col_count - len(row))\n\n\ndef wrap_text(text, width=78, initial_indent='', subsequent_indent='',\n              preserve_paragraphs=False):\n    \"\"\"A helper function that intelligently wraps text.  By default, it\n    assumes that it operates on a single paragraph of text but if the\n    `preserve_paragraphs` parameter is provided it will intelligently\n    handle paragraphs (defined by two empty lines).\n\n    If paragraphs are handled, a paragraph can be prefixed with an empty\n    line containing the ``\\\\b`` character (``\\\\x08``) to indicate that\n    no rewrapping should happen in that block.\n\n    :param text: the text that should be rewrapped.\n    :param width: the maximum width for the text.\n    :param initial_indent: the initial indent that should be placed on the\n                           first line as a string.\n    :param subsequent_indent: the indent string that should be placed on\n                              each consecutive line.\n    :param preserve_paragraphs: if this flag is set then the wrapping will\n                                intelligently handle paragraphs.\n    \"\"\"\n    from ._textwrap import TextWrapper\n    text = text.expandtabs()\n    wrapper = TextWrapper(width, initial_indent=initial_indent,\n                          subsequent_indent=subsequent_indent,\n                          replace_whitespace=False)\n    if not preserve_paragraphs:\n        return wrapper.fill(text)\n\n    p = []\n    buf = []\n    indent = None\n\n    def _flush_par():\n        if not buf:\n            return\n        if buf[0].strip() == '\\b':\n            p.append((indent or 0, True, '\\n'.join(buf[1:])))\n        else:\n            p.append((indent or 0, False, ' '.join(buf)))\n        del buf[:]\n\n    for line in text.splitlines():\n        if not line:\n            _flush_par()\n            indent = None\n        else:\n            if indent is None:\n                orig_len = term_len(line)\n                line = line.lstrip()\n                indent = orig_len - term_len(line)\n            buf.append(line)\n    _flush_par()\n\n    rv = []\n    for indent, raw, text in p:\n        with wrapper.extra_indent(' ' * indent):\n            if raw:\n                rv.append(wrapper.indent_only(text))\n            else:\n                rv.append(wrapper.fill(text))\n\n    return '\\n\\n'.join(rv)\n\n\nclass HelpFormatter(object):\n    \"\"\"This class helps with formatting text-based help pages.  It's\n    usually just needed for very special internal cases, but it's also\n    exposed so that developers can write their own fancy outputs.\n\n    At present, it always writes into memory.\n\n    :param indent_increment: the additional increment for each level.\n    :param width: the width for the text.  This defaults to the terminal\n                  width clamped to a maximum of 78.\n    \"\"\"\n\n    def __init__(self, indent_increment=2, width=None, max_width=None):\n        self.indent_increment = indent_increment\n        if max_width is None:\n            max_width = 80\n        if width is None:\n            width = FORCED_WIDTH\n            if width is None:\n                width = max(min(get_terminal_size()[0], max_width) - 2, 50)\n        self.width = width\n        self.current_indent = 0\n        self.buffer = []\n\n    def write(self, string):\n        \"\"\"Writes a unicode string into the internal buffer.\"\"\"\n        self.buffer.append(string)\n\n    def indent(self):\n        \"\"\"Increases the indentation.\"\"\"\n        self.current_indent += self.indent_increment\n\n    def dedent(self):\n        \"\"\"Decreases the indentation.\"\"\"\n        self.current_indent -= self.indent_increment\n\n    def write_usage(self, prog, args='', prefix='Usage: '):\n        \"\"\"Writes a usage line into the buffer.\n\n        :param prog: the program name.\n        :param args: whitespace separated list of arguments.\n        :param prefix: the prefix for the first line.\n        \"\"\"\n        usage_prefix = '%*s%s ' % (self.current_indent, prefix, prog)\n        text_width = self.width - self.current_indent\n\n        if text_width >= (term_len(usage_prefix) + 20):\n            # The arguments will fit to the right of the prefix.\n            indent = ' ' * term_len(usage_prefix)\n            self.write(wrap_text(args, text_width,\n                                 initial_indent=usage_prefix,\n                                 subsequent_indent=indent))\n        else:\n            # The prefix is too long, put the arguments on the next line.\n            self.write(usage_prefix)\n            self.write('\\n')\n            indent = ' ' * (max(self.current_indent, term_len(prefix)) + 4)\n            self.write(wrap_text(args, text_width,\n                                 initial_indent=indent,\n                                 subsequent_indent=indent))\n\n        self.write('\\n')\n\n    def write_heading(self, heading):\n        \"\"\"Writes a heading into the buffer.\"\"\"\n        self.write('%*s%s:\\n' % (self.current_indent, '', heading))\n\n    def write_paragraph(self):\n        \"\"\"Writes a paragraph into the buffer.\"\"\"\n        if self.buffer:\n            self.write('\\n')\n\n    def write_text(self, text):\n        \"\"\"Writes re-indented text into the buffer.  This rewraps and\n        preserves paragraphs.\n        \"\"\"\n        text_width = max(self.width - self.current_indent, 11)\n        indent = ' ' * self.current_indent\n        self.write(wrap_text(text, text_width,\n                             initial_indent=indent,\n                             subsequent_indent=indent,\n                             preserve_paragraphs=True))\n        self.write('\\n')\n\n    def write_dl(self, rows, col_max=30, col_spacing=2):\n        \"\"\"Writes a definition list into the buffer.  This is how options\n        and commands are usually formatted.\n\n        :param rows: a list of two item tuples for the terms and values.\n        :param col_max: the maximum width of the first column.\n        :param col_spacing: the number of spaces between the first and\n                            second column.\n        \"\"\"\n        rows = list(rows)\n        widths = measure_table(rows)\n        if len(widths) != 2:\n            raise TypeError('Expected two columns for definition list')\n\n        first_col = min(widths[0], col_max) + col_spacing\n\n        for first, second in iter_rows(rows, len(widths)):\n            self.write('%*s%s' % (self.current_indent, '', first))\n            if not second:\n                self.write('\\n')\n                continue\n            if term_len(first) <= first_col - col_spacing:\n                self.write(' ' * (first_col - term_len(first)))\n            else:\n                self.write('\\n')\n                self.write(' ' * (first_col + self.current_indent))\n\n            text_width = max(self.width - first_col - 2, 10)\n            wrapped_text = wrap_text(second, text_width, preserve_paragraphs=True)\n            lines = wrapped_text.splitlines()\n\n            if lines:\n                self.write(lines[0] + '\\n')\n\n                for line in lines[1:]:\n                    self.write('%*s%s\\n' % (first_col + self.current_indent, '', line))\n\n                if len(lines) > 1:\n                    # separate long help from next option\n                    self.write(\"\\n\")\n            else:\n                self.write('\\n')\n\n    @contextmanager\n    def section(self, name):\n        \"\"\"Helpful context manager that writes a paragraph, a heading,\n        and the indents.\n\n        :param name: the section name that is written as heading.\n        \"\"\"\n        self.write_paragraph()\n        self.write_heading(name)\n        self.indent()\n        try:\n            yield\n        finally:\n            self.dedent()\n\n    @contextmanager\n    def indentation(self):\n        \"\"\"A context manager that increases the indentation.\"\"\"\n        self.indent()\n        try:\n            yield\n        finally:\n            self.dedent()\n\n    def getvalue(self):\n        \"\"\"Returns the buffer contents.\"\"\"\n        return ''.join(self.buffer)\n\n\ndef join_options(options):\n    \"\"\"Given a list of option strings this joins them in the most appropriate\n    way and returns them in the form ``(formatted_string,\n    any_prefix_is_slash)`` where the second item in the tuple is a flag that\n    indicates if any of the option prefixes was a slash.\n    \"\"\"\n    rv = []\n    any_prefix_is_slash = False\n    for opt in options:\n        prefix = split_opt(opt)[0]\n        if prefix == '/':\n            any_prefix_is_slash = True\n        rv.append((len(prefix), opt))\n\n    rv.sort(key=lambda x: x[0])\n\n    rv = ', '.join(x[1] for x in rv)\n    return rv, any_prefix_is_slash\n", "path": "click/formatting.py"}]}