doc/tools/generate_modules.py
author julien tayon <julien.tayon@logilab.fr>
Tue, 11 Jun 2019 09:40:12 +0200
changeset 12640 de1c0721656e
parent 8930 6a02be304486
permissions -rw-r--r--
Fix sorting key for rdefs in schema viewer With changeset 234ca3cbbb46, clicking in the schema of an entity with cubicweb in py3 on "vue en boite" will probably result in an infinite spinner (which implies cw > 3.26) What happened ? This "vue en boite" used to work at least until... hg diff -c a8c1ea390400 cubicweb/schema.py @@ -993,10 +992,6 @@ class CubicWebRelationSchema(PermissionM return False return True - @deprecated('use .rdef(subjtype, objtype).role_cardinality(role)') - def cardinality(self, subjtype, objtype, target): - return self.rdef(subjtype, objtype).role_cardinality(target) - class CubicWebSchema(Schema): """set of entities and relations schema defining the possible data sets But, wait ... If I open a shell on an instance of cw 3.24 something seems off >>> list(schema['CWUniqueTogetherConstraint'].relation_definitions())[0][0].cardinality # <bound method CubicWebRelationSchema.wrapped of <constraint_of [CWUniqueTogetherConstraint,CWEType]>> We have been sorting on a method the whole time ? Is it possible what were the effects ? 1) We cannot sort function can't we ? >>> def adder(i): return lambda x: x+i >>> sorted(map(adder,range(10))) [<function __main__.<lambda>>, <function __main__.<lambda>>, ... Yes we can. 2) what does it means. >>> { adder(1) : 1 } Out[19]: {<function __main__.<lambda>>: 1} In fact the function object as a __hash__ method (which is practical for making memoizers (cache)), and return truly random results (pseudo random). My take on this patch is relations have NEVER been sorted by cardinality. No one never ever noticed. Hence, I propose to not fix a bug that never was reported.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
     1
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
     3
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
     4
# This file is part of CubicWeb.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
     5
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
     9
# any later version.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
    10
#
5424
8ecbcbff9777 replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5421
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
    14
# details.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
    15
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4831
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1808
diff changeset
    18
"""generate list of modules for sphinx doc
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1808
diff changeset
    19
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1808
diff changeset
    20
"""
1693
49075f57cf2c use logilab.common.sphinxutils
Emile Anclin <emile.anclin@logilab.fr>
parents: 299
diff changeset
    21
2612
c3059d308dc2 [doc] update generate_modules to match new sphinxutils API
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
    22
EXCLUDE_DIRS = ('test', 'tests', 'examples', 'data', 'doc', 'dist',
c3059d308dc2 [doc] update generate_modules to match new sphinxutils API
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
    23
                '.hg', 'migration')
1693
49075f57cf2c use logilab.common.sphinxutils
Emile Anclin <emile.anclin@logilab.fr>
parents: 299
diff changeset
    24
if __name__ == '__main__':
299
4761e0ca406d [doc] Adds scripts to auto-generate modules list to index and add to the documentation.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
diff changeset
    25
2612
c3059d308dc2 [doc] update generate_modules to match new sphinxutils API
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
    26
    from logilab.common.sphinxutils import ModuleGenerator
c3059d308dc2 [doc] update generate_modules to match new sphinxutils API
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
    27
    cw_gen = ModuleGenerator('cubicweb', '../..')
c3059d308dc2 [doc] update generate_modules to match new sphinxutils API
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
    28
    cw_gen.generate("../book/en/annexes/api_cubicweb.rst",
c3059d308dc2 [doc] update generate_modules to match new sphinxutils API
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
    29
                    EXCLUDE_DIRS + ('cwdesklets', 'misc', 'skel', 'skeleton'))
4831
c5aec27c1bf7 [repo] use logilab.db instead of lgc.adbh/lgc.db/lgc.sqlgen/indexer, test new date extranction functions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
    30
    for modname in ('logilab', 'rql', 'yams'):
2612
c3059d308dc2 [doc] update generate_modules to match new sphinxutils API
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
    31
        cw_gen = ModuleGenerator(modname, '../../../' + modname)
c3059d308dc2 [doc] update generate_modules to match new sphinxutils API
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
    32
        cw_gen.generate("../book/en/annexes/api_%s.rst" % modname,
c3059d308dc2 [doc] update generate_modules to match new sphinxutils API
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1977
diff changeset
    33
                        EXCLUDE_DIRS + ('tools',))