tp: fix stdlib docs parsing of multi-line view function return types
Change-Id: I28166eeafc5b0b275a0282375ad84a66cf801239
Bug: 287682786
diff --git a/python/BUILD.gn b/python/BUILD.gn
index 17ad6f3..dbd1e9d 100644
--- a/python/BUILD.gn
+++ b/python/BUILD.gn
@@ -26,7 +26,6 @@
sources = [
"generators/stdlib_docs/extractor.py",
"generators/stdlib_docs/parse.py",
- "generators/stdlib_docs/types.py",
"generators/stdlib_docs/utils.py",
]
}
diff --git a/python/generators/stdlib_docs/extractor.py b/python/generators/stdlib_docs/extractor.py
index 94db4d3..fce88f2 100644
--- a/python/generators/stdlib_docs/extractor.py
+++ b/python/generators/stdlib_docs/extractor.py
@@ -17,7 +17,7 @@
from re import Match
from typing import List, Optional, Tuple
-from python.generators.stdlib_docs.types import ObjKind
+from python.generators.stdlib_docs.utils import ObjKind
from python.generators.stdlib_docs.utils import extract_comment
from python.generators.stdlib_docs.utils import match_pattern
from python.generators.stdlib_docs.utils import PATTERN_BY_KIND
diff --git a/python/generators/stdlib_docs/parse.py b/python/generators/stdlib_docs/parse.py
index a78bcca..0bb4c28 100644
--- a/python/generators/stdlib_docs/parse.py
+++ b/python/generators/stdlib_docs/parse.py
@@ -20,7 +20,7 @@
from typing import Any, Dict, List, Optional, Set, Tuple, Union
from python.generators.stdlib_docs.extractor import DocsExtractor
-from python.generators.stdlib_docs.types import ObjKind
+from python.generators.stdlib_docs.utils import ObjKind
from python.generators.stdlib_docs.utils import ARG_ANNOTATION_PATTERN
from python.generators.stdlib_docs.utils import NAME_AND_TYPE_PATTERN
from python.generators.stdlib_docs.utils import FUNCTION_RETURN_PATTERN
diff --git a/python/generators/stdlib_docs/types.py b/python/generators/stdlib_docs/types.py
deleted file mode 100644
index a9baad3..0000000
--- a/python/generators/stdlib_docs/types.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2023 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the 'License');
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an 'AS IS' BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from enum import Enum
-
-
-class ObjKind(str, Enum):
- table_view = 'table_view'
- function = 'function'
- view_function = 'view_function'
diff --git a/python/generators/stdlib_docs/utils.py b/python/generators/stdlib_docs/utils.py
index eeccc01..d635b08 100644
--- a/python/generators/stdlib_docs/utils.py
+++ b/python/generators/stdlib_docs/utils.py
@@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from enum import Enum
import re
from typing import Dict, List
-from python.generators.stdlib_docs.types import ObjKind
-
LOWER_NAME = r'[a-z_\d]+'
UPPER_NAME = r'[A-Z_\d]+'
ANY_WORDS = r'[^\s].*'
+ANY_NON_QUOTE = r'[^\']*.*'
TYPE = r'[A-Z]+'
SQL = r'[\s\S]*?'
@@ -47,10 +47,17 @@
# Args: anything before closing bracket with '.
fr"({ANY_WORDS})\)',\s*"
# Return columns: anything between two '.
- fr"'\s*({ANY_WORDS})',\s*"
+ fr"'\s*({ANY_NON_QUOTE})\s*',\s*"
# Sql: Anything between ' and ');. We are catching \'.
fr"'({SQL})'\s*\);")
+
+class ObjKind(str, Enum):
+ table_view = 'table_view'
+ function = 'function'
+ view_function = 'view_function'
+
+
PATTERN_BY_KIND = {
ObjKind.table_view: CREATE_TABLE_VIEW_PATTERN,
ObjKind.function: CREATE_FUNCTION_PATTERN,
diff --git a/src/trace_processor/stdlib/experimental/thread_executing_span.sql b/src/trace_processor/stdlib/experimental/thread_executing_span.sql
index 338ec66..44bac68 100644
--- a/src/trace_processor/stdlib/experimental/thread_executing_span.sql
+++ b/src/trace_processor/stdlib/experimental/thread_executing_span.sql
@@ -339,6 +339,8 @@
-- @column blocked_dur Duration of blocking thread state before waking up.
-- @column blocked_state Thread state ('D' or 'S') of blocked thread_state before waking up.
-- @column blocked_function Kernel blocking function of thread state before waking up.
+-- @column is_root Whether this span is the root in the slice tree.
+-- @column is_leaf Whether this span is the leaf in the slice tree.
-- @column depth Tree depth from |root_id|
-- @column root_id Thread state id used to start the recursion. Helpful for SQL JOINs
SELECT CREATE_VIEW_FUNCTION(
@@ -410,6 +412,8 @@
-- @column blocked_dur Duration of blocking thread state before waking up.
-- @column blocked_state Thread state ('D' or 'S') of blocked thread_state before waking up.
-- @column blocked_function Kernel blocking function of thread state before waking up.
+-- @column is_root Whether this span is the root in the slice tree.
+-- @column is_leaf Whether this span is the leaf in the slice tree.
-- @column height Tree height from |leaf_id|
-- @column leaf_id Thread state id used to start the recursion. Helpful for SQL JOINs
SELECT CREATE_VIEW_FUNCTION(
diff --git a/tools/gen_stdlib_docs_json.py b/tools/gen_stdlib_docs_json.py
index 1f2e5be..dcb4023 100755
--- a/tools/gen_stdlib_docs_json.py
+++ b/tools/gen_stdlib_docs_json.py
@@ -71,6 +71,11 @@
import_key = path.split(".sql")[0].replace("/", ".")
docs = parse_file_to_dict(path, sql)
+ if isinstance(docs, list):
+ for d in docs:
+ print(d)
+ return 1
+
assert isinstance(docs, dict)
if not any(docs.values()):
continue