Skip to content
Snippets Groups Projects
Commit 7a15ca74 authored by Rosen Matev's avatar Rosen Matev :sunny:
Browse files

Use LbEnv for style checks and fix formatting

parent b0fa48b7
No related branches found
No related tags found
1 merge request!1043Use LbEnv for style checks and fix formatting
Pipeline #3084803 waiting for manual action
......@@ -31,8 +31,11 @@ check-copyright:
check-formatting:
stage: check
image: gitlab-registry.cern.ch/lhcb-docker/style-checker
tags:
- cvmfs
image: gitlab-registry.cern.ch/ci-tools/ci-worker:cc7
script:
- . /cvmfs/lhcb.cern.ch/lib/LbEnv.sh
- if [ ! -e .clang-format ] ; then
- curl -o .clang-format "https://gitlab.cern.ch/lhcb-core/LbDevTools/raw/master/LbDevTools/data/default.clang-format?inline=false"
- echo '.clang-format' >> .gitignore
......
......@@ -44,14 +44,12 @@ def read_LoKi_To_ThOr_table(filename):
if not thor_name:
continue
for loki_name in loki_functors:
mapping.append(
{
"loki_name": loki_name,
"thor_name": thor_name,
"equal_values": row[2],
"comment": row[3],
}
)
mapping.append({
"loki_name": loki_name,
"thor_name": thor_name,
"equal_values": row[2],
"comment": row[3],
})
assert (
regex_parse_thor.match(thor_name) is not None
......@@ -62,12 +60,10 @@ def read_LoKi_To_ThOr_table(filename):
def LoKi_To_ThOr_mapping():
standard_filename = os.path.join(
os.path.dirname(__file__), "selection/standard_loki_thor_table.csv"
)
os.path.dirname(__file__), "selection/standard_loki_thor_table.csv")
array_filename = os.path.join(
os.path.dirname(__file__), "selection/array_loki_thor_table.csv"
)
os.path.dirname(__file__), "selection/array_loki_thor_table.csv")
standard = read_LoKi_To_ThOr_table(standard_filename)
array = read_LoKi_To_ThOr_table(array_filename)
......@@ -95,11 +91,9 @@ def generate_LoKiDoc(mapping, namespace, thor_name):
comment = entry["comment"].strip()
if arguments_needed is not None:
comment = (
fr" :math:`\equiv` `{namespace}.{thortbl}"
f"({arguments_needed})`"
+ (" -- " + comment if len(comment) > 0 else "")
)
comment = (fr" :math:`\equiv` `{namespace}.{thortbl}"
f"({arguments_needed})`" +
(" -- " + comment if len(comment) > 0 else ""))
elif len(comment) > 0:
comment = " -- " + comment
......@@ -160,35 +154,31 @@ def gen_docs(namespaces, ignore_names=[]):
if hasattr(f, "headers") and hasattr(f, "code"):
if len(f.headers()) != 0:
fmt_header = ", ".join(
[f"`{h} <{gitlab_link}/{h}>`_" for h in f.headers()]
)
[f"`{h} <{gitlab_link}/{h}>`_" for h in f.headers()])
coderep = f"in {fmt_header}"
has_cppname = False
if (
hasattr(f, "_cppname")
and f._cppname is not None
and len(f._cppname.strip()) != 0
):
if (hasattr(f, "_cppname") and f._cppname is not None
and len(f._cppname.strip()) != 0):
coderep = f"``{f._cppname}`` " + (
coderep if coderep is not None else ""
)
coderep if coderep is not None else "")
has_cppname = True
if hasattr(f, "_code") and f._code is not None and not has_cppname:
if hasattr(
f,
"_code") and f._code is not None and not has_cppname:
coderep = f" ``{f._code.strip()}`` " + (
coderep if coderep is not None else ""
)
coderep if coderep is not None else "")
# comma-separated list of argument names.
args = (
", ".join([p[0] for p in f._arguments])
if hasattr(f, "_arguments")
else ""
)
print(f":: generate {name}.{functor_name}({args})", file=sys.stderr)
args = (", ".join([p[0] for p in f._arguments]) if hasattr(
f, "_arguments") else "")
print(
f":: generate {name}.{functor_name}({args})", file=sys.stderr)
# Start writing the Sphinx function block for this functor.
print(f".. py:function:: {name}.{functor_name}({args})\n")
print(textwrap.indent(inspect.cleandoc(f.__doc__), " " * 4, lambda _: True))
print(
textwrap.indent(
inspect.cleandoc(f.__doc__), " " * 4, lambda _: True))
print("")
# If we have found the corresponding C++ header, let the reader
......@@ -212,7 +202,10 @@ def gen_docs(namespaces, ignore_names=[]):
gen_docs(
{"Functors": F, "Functors.math": Fmath},
{
"Functors": F,
"Functors.math": Fmath
},
ignore_names=[
"test_bit",
"top_level_namespace",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment