From 1e6e0a22f60fafab475ae2c56dc89606ebea7dbf Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Mon, 25 Mar 2013 18:15:11 -0400 Subject: [PATCH 1/3] DOCS-1006: adding new interface elements and more refactoring --- bin/table_builder.py | 111 +++++++++++++++++++++++++------------------ 1 file changed, 66 insertions(+), 45 deletions(-) diff --git a/bin/table_builder.py b/bin/table_builder.py index fd1b575e231..24936ad3fdf 100644 --- a/bin/table_builder.py +++ b/bin/table_builder.py @@ -13,6 +13,7 @@ # limitations under the License. import sys +import argparse try: import yaml @@ -32,20 +33,15 @@ def normalize_cell_height(rowdata): for x in range(maxlines - len(cell)): cell.append( ' ' ) -def get_default_outputfile(inputfile): - return inputfile.rsplit('.')[0] + '.rst' - - ################################### # # Generating parts of the table. class YamlTable(object): def __init__(self, inputfile): - self.columnwidths = [] - self.tempcolumnwidths = [] + self.inputfile = inputfile self.read_data(inputfile) - self.process_table_content() + self.format = None def read_data(self, datafile): with open(datafile, "rt") as f: @@ -61,7 +57,8 @@ def read_data(self, datafile): elif content.section != 'content': exit('content document in "' + datafile + '" is malformed.') - rows = { 'rows': [] } + if hasattr(meta, 'format'): + format = meta.format if layout.header: header = [] @@ -70,14 +67,15 @@ def read_data(self, datafile): else: header = None + self.header = header + + rows = [] for rownum in layout.rows: - parsed_cell = [] + parsed_cells = [] for cell in rownum.items()[0][1]: - parsed_cell.append(eval(cell)) - rows['rows'].append( dict(zip(rownum.keys(), [parsed_cell])) ) + parsed_cells.append(eval(cell)) + rows.append( dict(zip(rownum.keys(), [parsed_cells])) ) - # return header, rows - self.header = header self.rows = rows @@ -104,17 +102,24 @@ def __getattr__(self, key): # # Interaction -class RstTable(YamlTable): - def __init__(self, inputfile): - self.inputfile = inputfile - super(RstTable, self).__init__(inputfile) +class OutputTable(object): + pass + +class RstTable(OutputTable): + def __init__(self, imported_table): + self.columnwidths = [] + self.tempcolumnwidths = [] + + self.table = imported_table + + self.process_table_content() self.output = self.render_table() ################################### # # Flexibility for tables of different sizes. - def check_column_width(self, rowdata): + def _check_column_width(self, rowdata): """ Compares the cell widths of the row with the curren max cell width in the global variables. Then updates @@ -134,13 +139,13 @@ def check_column_width(self, rowdata): # # Building the table representation - def get_row_line(self, delim='-'): + def _get_row_line(self, delim='-'): """ Produces and returns row deliminiters for restructured text tables. """ return '+' + delim + str(delim + '+' + delim).join([ delim * width for width in self.columnwidths ]) + delim + '+' - def get_row(self, rowdata): + def _get_row(self, rowdata): """ Returns rows given ``rowdata`` properly formated for restructured text tables. """ @@ -158,19 +163,19 @@ def process_table_content(self): # Compare cell widths of the header with the # max cell widths stored in the global var tempcolumnwidths # and swap out value(s) if necessary. - if self.header is not None: - self.check_column_width(self.header) + if self.table.header is not None: + self._check_column_width(self.table.header) - for index in range(len(self.rows['rows'])): + for index in range(len(self.table.rows)): parsed_row = [] # Append each cell to the parsed_row list, breaking multi-line # cell data as needed. - for cell in self.rows['rows'][index][index + 1]: + for cell in self.table.rows[index][index + 1]: parsed_row.append(cell.split('\n')) # process the data to ensure the table is big enough. - self.check_column_width(parsed_row) + self._check_column_width(parsed_row) normalize_cell_height(parsed_row) # add the processed data to the table @@ -183,22 +188,22 @@ def process_table_content(self): def render_table(self): o = [] - o.append(self.get_row_line()) + o.append(self._get_row_line()) - if self.header is not None: - o.append(self.get_row(self.header)) - o.append(self.get_row_line('=')) + if self.table.header is not None: + o.append(self._get_row(self.table.header)) + o.append(self._get_row_line('=')) - for self.row in self.tabledata: - o.append(self.get_row(self.row)) - o.append(self.get_row_line()) + for row in self.tabledata: + o.append(self._get_row(row)) + o.append(self._get_row_line()) return o -class ListTable(YamlTable): +class ListTable(OutputTable): pass -class HtmlTable(YamlTable): +class HtmlTable(OutputTable): pass class TableBuilder(object): @@ -221,22 +226,38 @@ def print_table(self): # # Interface. +def get_outputfile(inputfile, outputfile): + if outputfile is None: + return inputfile.rsplit('.')[0] + '.rst' + else: + return outputfile + +def user_input(formats): + parser = argparse.ArgumentParser('YAML to (RST/HTML) Table Builder') + parser.add_argument('input', nargs='?', help='path of source yaml file.') + + output_help = 'path of output file. by default, the input file name with an ".rst" extension.' + parser.add_argument('output', nargs='?', default=None, help=output_help) + parser.add_argument('--type', '-t', choices=formats, default='rst', + help='output table format.') + + return parser.parse_args() + def main(): - # the following is a total hack to avoid argparse. first argument - # is input, second is output. we'll have to break down and use - # argparse if we want any other options, just for sanity. + formats = { 'rst': RstTable, + 'list': ListTable, + 'html': HtmlTable } + + ui = user_input(formats.keys()) - inputfile = sys.argv[1] + table_data = YamlTable(ui.input) - try: - outputfile = sys.argv[2] - except IndexError: - outputfile = get_default_outputfile(inputfile) + if table_data.format is None: + table_data.format = ui.type - table = RstTable(inputfile) - output = TableBuilder(table) + table = TableBuilder(formats[table_data.format](table_data)) - output.write(outputfile) + table.write(get_outputfile(ui.input, ui.output)) if __name__ == '__main__': main() From 947ce825c0b8c74ae411d5a8dd9d71ce409580d7 Mon Sep 17 00:00:00 2001 From: Jason Rassi Date: Mon, 25 Mar 2013 18:34:38 -0400 Subject: [PATCH 2/3] Fix incorrect statements in 2.4 upgrade notes about new index types --- source/release-notes/2.4-index-types.txt | 8 ++++---- source/release-notes/2.4-upgrade.txt | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/source/release-notes/2.4-index-types.txt b/source/release-notes/2.4-index-types.txt index 38902a4021a..aa3005ec89d 100644 --- a/source/release-notes/2.4-index-types.txt +++ b/source/release-notes/2.4-index-types.txt @@ -36,10 +36,10 @@ did not exist. In these situations, MongoDB would create an ascending strings that do not refer to an existing index type, and all numbers other than ``1`` and ``-1``. [#grandfathered-indexes]_ -In 2.4, after you create the first ``2dsphere`` or ``text`` index, -creating any invalid index will result in an error. Furthermore, you -cannot create a ``2dsphere`` or ``text`` index if your databases have -any invalid index types. [#grandfathered-indexes]_ +In 2.4, creating any invalid index will result in an error. +Furthermore, you cannot create a ``2dsphere`` or ``text`` index on a +collection if its containing database has any invalid index types. +[#grandfathered-indexes]_ .. [#grandfathered-indexes] In 2.4, indexes that specify a type of ``"1"`` or ``"-1"`` (the strings ``"1"`` and ``"-1"``) will continue diff --git a/source/release-notes/2.4-upgrade.txt b/source/release-notes/2.4-upgrade.txt index afc84b52c60..85de926249e 100644 --- a/source/release-notes/2.4-upgrade.txt +++ b/source/release-notes/2.4-upgrade.txt @@ -461,10 +461,6 @@ Considerations and Compatibility If you upgrade to MongoDB 2.4, and then need to run MongoDB 2.2 with the same data files, consider the following limitations. -- ``2dsphere`` and ``text`` indexes do not exist in 2.2. If you - downgrade to 2.2, you cannot use these indexes in 2.2. and you will - need to rebuild these indexes if you later upgrade to 2.4. - - If you use a ``hashed`` index as the shard key index, which is only possible under 2.4 you will not be able to query data in this sharded collection. Furthermore, a 2.2 :program:`mongos` cannot From 5d46c63c85d8dea9e4e105366215439a1944fbd7 Mon Sep 17 00:00:00 2001 From: Ernie Hershey Date: Mon, 25 Mar 2013 16:37:25 -0400 Subject: [PATCH 3/3] DOCS-1283 Clarify and cleanup system specific installation instructions DOCS-1283 Add 'Although' (to clarify distinction between our packages and Ubuntu packages) 1) Add "although" to first paragraph on Ubuntu page DOCS-1283 Clarify Debian/Ubuntu note (Rewording to make the relevance of the note clearer.) 2) Clarify note on Debian page about applying to Ubuntu DOCS-1283 Remove vague "See Also" in Synopsis (other install pages seem to serve the same purpose) 3) Remove equivalent text across the pages by "See Also" - "The documentation of following related processes and concepts." DOCS-1283 Remove confusing production sentence 4) Remove "Use this for production deployments." which made more sense when multiple packages were on the page. DOCS-1283 Clarify package conflict wording. DOCS-1283 Rewording package descriptions Trying to make it clearer which package is which. your release of Ubuntu may provide -> provided by Ubuntu change text for other installation tutorials to a See: header --- source/tutorial/install-mongodb-on-debian.txt | 21 ++++++++----------- source/tutorial/install-mongodb-on-linux.txt | 5 +---- source/tutorial/install-mongodb-on-os-x.txt | 5 +---- ...godb-on-red-hat-centos-or-fedora-linux.txt | 15 ++++++------- source/tutorial/install-mongodb-on-ubuntu.txt | 16 ++++++-------- 5 files changed, 23 insertions(+), 39 deletions(-) diff --git a/source/tutorial/install-mongodb-on-debian.txt b/source/tutorial/install-mongodb-on-debian.txt index 082f1b6c42c..c77665fdac1 100644 --- a/source/tutorial/install-mongodb-on-debian.txt +++ b/source/tutorial/install-mongodb-on-debian.txt @@ -22,14 +22,12 @@ configuration and operation. .. note:: - If you're running a version of Ubuntu Linux prior to 9.10 "Karmic," - use this tutorial. Other Ubuntu users will want to follow - the :doc:`/tutorial/install-mongodb-on-ubuntu` tutorial. + This tutorial applies to both Debian systems and versions of Ubuntu + Linux prior to 9.10 "Karmic" which do not use Upstart. Other Ubuntu + users will want to follow the :doc:`/tutorial/install-mongodb-on-ubuntu` + tutorial. -.. seealso:: The documentation of following related processes and - concepts. - - Other installation tutorials: +.. see:: Additional installation tutorials: - :doc:`/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux` - :doc:`/tutorial/install-mongodb-on-ubuntu` @@ -46,12 +44,11 @@ Package Options --------------- The 10gen repository provides the ``mongodb-10gen`` package, -which contains the latest **stable** release. Use this for production -deployments. Additionally you can :ref:`install previous -releases ` of MongoDB. +which contains the latest **stable** release. Additionally you can +:ref:`install previous releases ` of MongoDB. -You cannot install these packages concurrently with each other or with -the ``mongodb`` package that your release of Debian may include. +You cannot install this package concurrently with the ``mongodb`` package that +your release of Debian may include. Installing MongoDB ------------------ diff --git a/source/tutorial/install-mongodb-on-linux.txt b/source/tutorial/install-mongodb-on-linux.txt index 445268f22cc..099458fc66e 100644 --- a/source/tutorial/install-mongodb-on-linux.txt +++ b/source/tutorial/install-mongodb-on-linux.txt @@ -12,10 +12,7 @@ that provides a simple option for users who cannot use packages. This tutorial outlines the basic installation of MongoDB using these compiled versions and an initial usage guide. -.. seealso:: The documentation of following related processes and - concepts. - - Other installation tutorials: +.. see:: Additional installation tutorials: - :doc:`/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux` - :doc:`/tutorial/install-mongodb-on-ubuntu` diff --git a/source/tutorial/install-mongodb-on-os-x.txt b/source/tutorial/install-mongodb-on-os-x.txt index 0d4d36a5544..dce6e49cb45 100644 --- a/source/tutorial/install-mongodb-on-os-x.txt +++ b/source/tutorial/install-mongodb-on-os-x.txt @@ -20,10 +20,7 @@ main methods of installing the MongoDB server community package management tools, and second using builds of MongoDB provided by 10gen. -.. seealso:: The documentation of following related processes and - concepts. - - Other installation tutorials: +.. see:: Additional installation tutorials: - :doc:`/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux` - :doc:`/tutorial/install-mongodb-on-ubuntu` diff --git a/source/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux.txt b/source/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux.txt index 13d641ffcdd..1a4d8811379 100644 --- a/source/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux.txt +++ b/source/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux.txt @@ -21,10 +21,7 @@ instructions for configuring the package manager, the process install packages from the 10gen repository, and preliminary MongoDB configuration and operation. -.. seealso:: The documentation of following related processes and - concepts. - - Other installation tutorials: +.. see:: Additional installation tutorials: - :doc:`/tutorial/install-mongodb-on-debian-or-ubuntu-linux` - :doc:`/tutorial/install-mongodb-on-debian` @@ -48,15 +45,15 @@ The 10gen repository contains two packages: This package contains the :program:`mongod` and :program:`mongos` daemons from the latest **stable** release and associated configuration and init scripts. Additionally, you can use this - package to :ref:`install tools from a previous release + package to :ref:`install daemons from a previous release ` of MongoDB. - ``mongo-10gen`` - By default, this package contains all MongoDB tools from latest - **stable** release and you can use this package to :ref:`install - previous releases ` of - MongoDB. Install this package on all production MongoDB hosts and + This package contains all MongoDB tools from the latest **stable** + release. Additionally, you can use this package to :ref:`install tools from a previous + release ` of MongoDB. + Install this package on all production MongoDB hosts and optionally on other systems from which you may need to administer MongoDB systems. diff --git a/source/tutorial/install-mongodb-on-ubuntu.txt b/source/tutorial/install-mongodb-on-ubuntu.txt index c02a0fed212..6fbe4c639b5 100644 --- a/source/tutorial/install-mongodb-on-ubuntu.txt +++ b/source/tutorial/install-mongodb-on-ubuntu.txt @@ -11,7 +11,7 @@ This tutorial outlines the basic installation process for installing :term:`MongoDB` on Ubuntu Linux systems. This tutorial uses ``.deb`` packages as the basis of the installation. 10gen publishes packages of the MongoDB releases as ``.deb`` packages for easy -installation and management for users of Ubuntu systems. Ubuntu does +installation and management for users of Ubuntu systems. Although Ubuntu does include MongoDB packages, the 10gen packages are generally more up to date. @@ -26,10 +26,7 @@ configuration and operation. version before 9.10 "Karmic") please follow the instructions on the :doc:`install-mongodb-on-debian` tutorial. -.. seealso:: The documentation of following related processes and - concepts. - - Other installation tutorials: +.. see:: Additional installation tutorials: - :doc:`/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux` - :doc:`/tutorial/install-mongodb-on-debian` @@ -46,12 +43,11 @@ Package Options --------------- The 10gen repository provides the ``mongodb-10gen`` package, -which contains the latest **stable** release. Use this for production -deployments. Additionally you can :ref:`install previous -releases ` of MongoDB. +which contains the latest **stable** release. Additionally you can +:ref:`install previous releases ` of MongoDB. -You cannot install these packages concurrently with each other or with -the ``mongodb`` package that your release of Ubuntu may include. +You cannot install this package concurrently with the ``mongodb`` package +provided by Ubuntu. Installing MongoDB ------------------