Skip to content

Commit fb15879

Browse files
authored
Add a suppress_publish field to example metadata (#191)
* Add suppress_publish field to Example meta. * Get unit tests passing.
1 parent c2fd031 commit fb15879

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

aws_doc_sdk_examples_tools/doc_gen_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def test_doc_gen_encoder(sample_doc_gen: DocGen):
253253
assert "examples" in decoded
254254
assert decoded["examples"] == {
255255
"s3_PutObject": {
256+
"suppress_publish": False,
256257
"category": None,
257258
"doc_filenames": None,
258259
"file": "filea.txt",

aws_doc_sdk_examples_tools/fs.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ def __init__(self, fs: Dict[Path, str]):
8585
self.fs = fs
8686

8787
def glob(self, path: Path, glob: str) -> Generator[Path, None, None]:
88-
path_s = str(path)
88+
path_s = path.as_posix()
8989
for key in self.fs.keys():
90-
key_s = str(key)
90+
key_s = key.as_posix()
9191
if key_s.startswith(path_s):
9292
if fnmatch(key_s, glob):
9393
yield key
@@ -100,17 +100,17 @@ def readlines(self, path: Path, encoding: str = "utf-8") -> List[str]:
100100
return content.splitlines(keepends=True)
101101

102102
def write(self, path: Path, content: str):
103-
base = str(path.parent)
103+
base = path.parent.as_posix()
104104
assert any(
105-
[str(key).startswith(base) for key in self.fs]
105+
[key.as_posix().startswith(base) for key in self.fs]
106106
), "No parent folder, this will probably fail without a call to mkdir in a real file system!"
107107
self.fs[path] = content
108108

109109
def stat(self, path: Path):
110110
if path in self.fs:
111111
return Stat(path, True, True)
112112
for item in self.fs.keys():
113-
if str(item).startswith(str(path)):
113+
if item.as_posix().startswith(path.as_posix()):
114114
return Stat(path, True, False)
115115
return Stat(path, False, False)
116116

@@ -123,11 +123,11 @@ def list(self, path: Path) -> List[Path]:
123123
return []
124124

125125
# Gather all entries that are immediate children of `path`
126-
prefix = str(path).rstrip("/") + "/"
126+
prefix = path.as_posix().rstrip("/") + "/"
127127
children = set()
128128

129129
for item in self.fs.keys():
130-
item_s = str(item)
130+
item_s = item.as_posix()
131131
if item_s.startswith(prefix):
132132
# Determine the remainder path after the prefix
133133
remainder = item_s[len(prefix) :]

aws_doc_sdk_examples_tools/metadata.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ class Example:
161161
doc_filenames: Optional[DocFilenames] = field(default=None)
162162
synopsis_list: List[str] = field(default_factory=list)
163163
source_key: Optional[str] = field(default=None)
164+
suppress_publish: Optional[bool] = field(default=False)
164165

165166
def fill_display_fields(self, categories: Dict[str, Category], service, action):
166167
category = self.choose_category(categories)

aws_doc_sdk_examples_tools/yaml_writer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def prepare_write(examples: Dict[str, Example]) -> Dict[str, str]:
5050
# "doc_filenames", # These are currently generated, and don't need to be stored.
5151
"source_key",
5252
"category",
53+
"suppress_publish",
5354
"languages",
5455
"service_main",
5556
"services",

0 commit comments

Comments
 (0)