doc: boards: extensions: simplify DTS binding description extraction
Previous implementation was unneccesarily complex, and cutting of words such as "802.15.4" to "802.". Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit is contained in:
parent
bace008d89
commit
4ddfe10b89
1 changed files with 13 additions and 19 deletions
|
@ -4,6 +4,7 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
@ -36,28 +37,21 @@ class DeviceTreeUtils:
|
||||||
The first sentence found in the text, or the entire text if no sentence
|
The first sentence found in the text, or the entire text if no sentence
|
||||||
boundary is found.
|
boundary is found.
|
||||||
"""
|
"""
|
||||||
# Split the text into lines
|
if not text:
|
||||||
lines = text.splitlines()
|
|
||||||
|
|
||||||
# Trim leading and trailing whitespace from each line and ignore completely blank lines
|
|
||||||
lines = [line.strip() for line in lines]
|
|
||||||
|
|
||||||
if not lines:
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
# Case 1: Single line followed by blank line(s) or end of text
|
text = text.replace('\n', ' ')
|
||||||
if len(lines) == 1 or (len(lines) > 1 and lines[1] == ""):
|
# Split by double spaces to get paragraphs
|
||||||
first_line = lines[0]
|
paragraphs = text.split(' ')
|
||||||
# Check for the first period
|
first_paragraph = paragraphs[0].strip()
|
||||||
period_index = first_line.find(".")
|
|
||||||
# If there's a period, return up to the period; otherwise, return the full line
|
|
||||||
return first_line[: period_index + 1] if period_index != -1 else first_line
|
|
||||||
|
|
||||||
# Case 2: Multiple contiguous lines, treat as a block
|
# Look for a period followed by a space in the first paragraph
|
||||||
block = " ".join(lines)
|
period_match = re.search(r'(.*?)\.(?:\s|$)', first_paragraph)
|
||||||
period_index = block.find(".")
|
if period_match:
|
||||||
# If there's a period, return up to the period; otherwise, return the full block
|
return period_match.group(1).strip()
|
||||||
return block[: period_index + 1] if period_index != -1 else block
|
|
||||||
|
# If no period in the first paragraph, return the entire first paragraph
|
||||||
|
return first_paragraph
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_cached_description(cls, node):
|
def get_cached_description(cls, node):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue