Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix package extraction #80

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix package extraction
fixes #79
  • Loading branch information
EugenDueck committed Dec 13, 2024
commit b742bcd039a735e35d1320809eb8582ee53081de
15 changes: 13 additions & 2 deletions src/sabledocs/proto_descriptor_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,28 @@ def extract_package_name_from_full_name(full_type_name: str):
return full_type_name[:last_dot]


def extract_package_name_from_message(message: Message) -> str:
if message.is_map_entry:
assert message.full_name.endswith(".XEntry")
name_without_xentry = message.full_name.removesuffix(".XEntry")
return extract_package_name_from_full_name(name_without_xentry)
else:
return extract_package_name_from_full_name(message.full_name)


def add_package_references(messages: list[Message], services: list[Service], packages: list[Package], hidden_packages: list[str]):
for m in messages:
package = next(filter(lambda p: m.full_name.startswith(p.name), packages), None)
m_package_name = extract_package_name_from_message(m)
package = next(filter(lambda p: m_package_name == p.name, packages), None)
if package is not None:
m.package = package

for mf in m.fields:
if mf.full_type == "":
continue

package = next(filter(lambda p: mf.full_type.startswith(p.name), packages), None)
mf_package_name = extract_package_name_from_full_name(mf.full_type)
package = next(filter(lambda p: mf_package_name == p.name, packages), None)
if package is not None:
mf.package = package
mf.is_package_hidden = any(filter(lambda p: mf.full_type.startswith(p), hidden_packages))
Expand Down