Skip to content

Commit 01a38f8

Browse files
DOC-5804 added build code changes to extract value into
1 parent d2b5862 commit 01a38f8

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

build/components/component.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ def _copy_examples(self):
273273
example_metadata['sourceUrl'] = (
274274
f'{ex["git_uri"]}/tree/{default_branch}/{ex["path"]}/{os.path.basename(f)}'
275275
)
276+
277+
# Add binderId only if it exists
278+
if e.binder_id:
279+
example_metadata['binderId'] = e.binder_id
280+
276281
examples = self._root._examples
277282
if example_id not in examples:
278283
examples[example_id] = {}

build/components/example.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
STEP_START = 'STEP_START'
99
STEP_END = 'STEP_END'
1010
EXAMPLE = 'EXAMPLE:'
11+
BINDER_ID = 'BINDER_ID'
1112
GO_OUTPUT = 'Output:'
1213
TEST_MARKER = {
1314
'java': '@Test',
@@ -45,6 +46,7 @@ class Example(object):
4546
hidden = None
4647
highlight = None
4748
named_steps = None
49+
binder_id = None
4850

4951
def __init__(self, language: str, path: str) -> None:
5052
logging.debug("ENTERING: ")
@@ -59,6 +61,7 @@ def __init__(self, language: str, path: str) -> None:
5961
self.hidden = []
6062
self.highlight = []
6163
self.named_steps = {}
64+
self.binder_id = None
6265
self.make_ranges()
6366
self.persist(self.path)
6467
logging.debug("EXITING: ")
@@ -88,6 +91,7 @@ def make_ranges(self) -> None:
8891
rstart = re.compile(f'{PREFIXES[self.language]}\\s?{REMOVE_START}')
8992
rend = re.compile(f'{PREFIXES[self.language]}\\s?{REMOVE_END}')
9093
exid = re.compile(f'{PREFIXES[self.language]}\\s?{EXAMPLE}')
94+
binder = re.compile(f'{PREFIXES[self.language]}\\s?{BINDER_ID}\\s+([a-f0-9]{{40}})')
9195
go_output = re.compile(f'{PREFIXES[self.language]}\\s?{GO_OUTPUT}')
9296
go_comment = re.compile(f'{PREFIXES[self.language]}')
9397
test_marker = re.compile(f'{TEST_MARKER.get(self.language)}')
@@ -150,6 +154,13 @@ def make_ranges(self) -> None:
150154
elif re.search(exid, l):
151155
output = False
152156
pass
157+
elif re.search(binder, l):
158+
# Extract BINDER_ID hash value
159+
match = re.search(binder, l)
160+
if match:
161+
self.binder_id = match.group(1)
162+
logging.debug(f'Found BINDER_ID: {self.binder_id} in {self.path}:L{curr+1}')
163+
output = False
153164
elif self.language == "go" and re.search(go_output, l):
154165
if output:
155166
logging.error("Nested Go Output anchor in {self.path}:L{curr+1} - aborting.")

build/local_examples.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ def process_local_examples(local_examples_dir: str = 'local_examples',
180180
'sourceUrl': None # Local examples don't have source URLs
181181
}
182182

183+
# Add binderId only if it exists
184+
if example.binder_id:
185+
example_metadata['binderId'] = example.binder_id
186+
183187
examples_data[example_id][client_name] = example_metadata
184188
logging.info(f"Processed {client_name} example for {example_id}")
185189

0 commit comments

Comments
 (0)