|
| 1 | +#------------------------------------------------------------------------------ |
| 2 | +# Copyright (c) 2024, Oracle and/or its affiliates. |
| 3 | +# |
| 4 | +# This software is dual-licensed to you under the Universal Permissive License |
| 5 | +# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License |
| 6 | +# 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose |
| 7 | +# either license. |
| 8 | +# |
| 9 | +# If you elect to accept the software under the Apache License, Version 2.0, |
| 10 | +# the following applies: |
| 11 | +# |
| 12 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 13 | +# you may not use this file except in compliance with the License. |
| 14 | +# You may obtain a copy of the License at |
| 15 | +# |
| 16 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 17 | +# |
| 18 | +# Unless required by applicable law or agreed to in writing, software |
| 19 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 20 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 21 | +# See the License for the specific language governing permissions and |
| 22 | +# limitations under the License. |
| 23 | +#------------------------------------------------------------------------------ |
| 24 | + |
| 25 | +#------------------------------------------------------------------------------ |
| 26 | +# constants_table.py |
| 27 | +# |
| 28 | +# Defines a directive (constants-table) that creates a table with a specific |
| 29 | +# configuration on top of the extended "list-table-with-summary" directive. |
| 30 | +#------------------------------------------------------------------------------ |
| 31 | + |
| 32 | +from docutils.statemachine import ViewList |
| 33 | + |
| 34 | +import table_with_summary |
| 35 | + |
| 36 | +class ConstantsTable(table_with_summary.ListTableWithSummary): |
| 37 | + |
| 38 | + def run(self): |
| 39 | + self.options["summary"] = \ |
| 40 | + "The first column displays the name of the constant. The " \ |
| 41 | + "second column displays the value of the constant. The third " \ |
| 42 | + "column displays the description of the constant." |
| 43 | + self.options["header-rows"] = 1 |
| 44 | + self.options["class"] = ["wy-table-responsive"] |
| 45 | + self.options["widths"] = [40, 15, 45] |
| 46 | + self.options["width"] = "100%" |
| 47 | + headings = ViewList(['* - Constant Name', ' - Value', ' - Description']) |
| 48 | + self.content = headings + self.content |
| 49 | + return super().run() |
| 50 | + |
| 51 | +def setup(app): |
| 52 | + app.add_directive('constants-table', ConstantsTable) |
0 commit comments