Compare commits

...

6 Commits

Author SHA1 Message Date
556316d858 fixing conversion of element li 2023-03-29 08:42:12 +00:00
cb7902cbe6 fixing code element in unit test 2023-03-29 08:32:59 +00:00
eed7f61f02 small fix on testunit 2023-03-29 08:23:36 +00:00
5239181c81 adding rds fix for /* ... */ match which should also conver mrs previous
match
2023-03-29 07:45:57 +00:00
f15f2de664 adding new services in metadata and zuul
Reviewed-by: tischrei <tino.schreiber@t-systems.com>
Co-authored-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-committed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
2023-03-27 10:56:19 +00:00
f173c9af19 Adding new rule for colon and asterisk combination
Reviewed-by: gtema <artem.goncharov@gmail.com>
Co-authored-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-committed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
2023-03-23 14:47:06 +00:00
7 changed files with 123 additions and 12 deletions

View File

@ -20,6 +20,23 @@ categories:
- name: docs-security-services-rw
permission: write
repository: docs/anti-ddos
- service_title: Database Security Service
service_type: dbss
docs:
- html_location: docs/dbss/api-ref
rst_location: api-ref/source
title: API Reference
type: api-ref
pdf_name: dbss-api-ref
- html_location: docs/dbss/umn
rst_location: umn/source
title: User Guide
type: umn
pdf_name: dbss-umn
teams:
- name: docs-security-services-rw
permission: write
repository: docs/database-security-service
- service_title: Identity and Access Management
service_type: iam
docs:
@ -851,6 +868,23 @@ categories:
- name: docs-network-rw
permission: write
repository: docs/elastic-load-balancing
- service_title: Enterprise Router
service_type: er
docs:
- html_location: docs/er/api-ref
rst_location: api-ref/source
title: API Reference
type: api-ref
pdf_name: er-api-ref
- html_location: docs/er/umn
rst_location: umn/source
title: User Guide
type: umn
pdf_name: er-umn
teams:
- name: docs-network-rw
permission: write
repository: docs/enterprise-router
- service_title: NAT Gateway
service_type: natgw
docs:

View File

@ -403,7 +403,8 @@ class OTCDocConvertor:
# MRS UMN contain: /:*?"<>|\\;&,'`!{}[]$%+
r"\s([^a-zA-Z0-9\s]{8,})",
# MRS operation guide contain: /*+ MAPJOIN(join_table) \*/
r"\s(/\*.*\*/)",
# RDS UMN contain: /*FORCE_MASTER*/
r"(/\*.{5,}\*/)",
# BMS API contain sequence in a dedicated paragraph
r"^([^a-zA-Z0-9\s]{10,})$",
# OBS special chars - "\$" "\\" etc
@ -423,7 +424,7 @@ class OTCDocConvertor:
]
self.rawize_me(soup, rawize_strings)
# Pandoc seem to be not escaping properly asterists which are
# Pandoc seem to be not escaping properly asterisks which are
# immediately following non word chars
# (https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#toc-entry-44)
# NOTE(gtema):
@ -431,12 +432,26 @@ class OTCDocConvertor:
# escapings above
# 2. we are not escaping asterisks at the end of the paragraphs (pandoc
# deals correctly with that)
re_escape = re.compile(r"([-:/'\"<\([{])(\*+)(.)")
re_escape = re.compile(r"([-/'\"<\([{])(\*+)(.)")
for p in soup.body.find_all(string=re_escape):
if p.string and p.parent.name == "p":
p.string.replace_with(
re.sub(re_escape, r"\1``\2``\3", p.string))
# Special case for multiple asterisks and colons like ecs:*:*
re_escape = re.compile(r"([:])(\*+)")
re_escape_new = re.compile(r"([:])(\*)[^$]")
for p in soup.body.find_all(string=re_escape):
if p.string and (p.parent.name == "p" or p.parent.name == "li"):
string = p.string
while re.search(re_escape, string):
if re.search(re_escape_new, string):
string = re.sub(
re_escape, r"\1``\2``", string, count=1)
else:
break
p.string.replace_with(string)
# Drop parent link at the bottom of the page
for parent in soup.body.find_all("p", class_="familylinks"):
parent.decompose()

View File

@ -65,7 +65,7 @@ class TestConvertor(TestCase):
Turbo instance, including the permissions for verifying VPCs, subnets,
and security groups, creating virtual IP addresses and ports, and
creating security group rules. You must add the following
action:<ul><li>"vpc:*:*"</li></ul></li></ul></td>
action:<ul><li>"vpc:``*``:``*``"</li></ul></li></ul></td>
"""
soup = bs4.BeautifulSoup(test_data, 'lxml')
res = self.convertor.streamline_html(soup, "dummy")
@ -76,7 +76,7 @@ class TestConvertor(TestCase):
<ul><li>"dss:*:get",</li><li>"dss:*:list",</li><li>"dss:*:count"</li></ul>
"""
expected = """
<ul><li>"dss:*:get",</li><li>"dss:*:list",</li><li>"dss:*:count"</li></ul>
<ul><li>"dss:``*``:get",</li><li>"dss:``*``:list",</li><li>"dss:``*``:count"</li></ul>
"""
soup = bs4.BeautifulSoup(test_data, 'lxml')
res = self.convertor.streamline_html(soup, "dummy")
@ -87,7 +87,7 @@ class TestConvertor(TestCase):
<ul><li>"vpc:*:*"</li></ul>
"""
expected = """
<ul><li>"vpc:*:*"</li></ul>
<ul><li>"vpc:``*``:``*``"</li></ul>
"""
soup = bs4.BeautifulSoup(test_data, 'lxml')
res = self.convertor.streamline_html(soup, "dummy")
@ -163,3 +163,59 @@ class TestConvertor(TestCase):
str(res.find('td')),
expected.strip(),
)
def test_streamline_html_escape_12(self):
test_data= """
<p id="dli_03_0101__en-us_topic_0000001174688342_p1256384461610">DLI:*:*:database:databases.dbname</p>
""" # noqa
expected = """
<p id="dli_03_0101__en-us_topic_0000001174688342_p1256384461610">DLI:``*``:``*``:database:databases.dbname</p>
""" # noqa
soup = bs4.BeautifulSoup(test_data, 'lxml')
res = self.convertor.streamline_html(soup, "dummy")
self.assertEqual(
str(res.find('p')),
expected.strip(),
)
def test_streamline_html_escape_13(self):
test_data= """
<p id="dli_03_0101__en-us_topic_0000001174688342_p4564244131615">DLI:*:*:queue:queues.*</p>
""" # noqa
expected = """
<p id="dli_03_0101__en-us_topic_0000001174688342_p4564244131615">DLI:``*``:``*``:queue:queues.*</p>
""" # noqa
soup = bs4.BeautifulSoup(test_data, 'lxml')
res = self.convertor.streamline_html(soup, "dummy")
self.assertEqual(
str(res.find('p')),
expected.strip(),
)
def test_streamline_html_escape_14(self):
test_data= """
<li id="mrs_01_0979__en-us_topic_0000001173470738_en-us_topic_0116526932_li53294272">Use /*+ MAPJOIN(join_table) */.</li>
""" # noqa
expected = """
<li>Use <code>/*+ MAPJOIN(join_table) */</code>.</li>
""" # noqa
soup = bs4.BeautifulSoup(test_data, 'lxml')
res = self.convertor.streamline_html(soup, "dummy")
self.assertEqual(
str(res.find('li')),
expected.strip(),
)
def test_streamline_html_escape_15(self):
test_data= """
<p id="rds_11_0020__en-us_topic_0200110324_p133410225015">/*FORCE_MASTER*/: A SQL statement is routed to the primary DB instance.</p>
""" # noqa
expected = """
<p id="rds_11_0020__en-us_topic_0200110324_p133410225015"><code>/*FORCE_MASTER*/</code>: A SQL statement is routed to the primary DB instance.</p>
""" # noqa
soup = bs4.BeautifulSoup(test_data, 'lxml')
res = self.convertor.streamline_html(soup, "dummy")
self.assertEqual(
str(res.find('p')),
expected.strip(),
)

View File

@ -1,4 +1,5 @@
bs4
lxml
Jinja2
requests
bs4>=0.0.1
beautifulsoup4>=4.0 # MIT
lxml>=4.9 # BSD-3-Clause
Jinja2>=3.1 # BSD-3-Clause
requests>=2.28 # Apache-2.0

View File

@ -1 +1,2 @@
flake8
flake8>=6.0 # MIT
stestr>=4.0 # Apache-2.0

View File

@ -1,6 +1,6 @@
[tox]
minversion = 3.6
envlist = pep8
envlist = py3,pep8
skipsdist = True
ignore_basepython_conflict = True
@ -15,6 +15,8 @@ setenv =
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = stestr run {posargs}
stestr slowest
[testenv:pep8]
commands =

View File

@ -123,6 +123,7 @@
- docs/dns
- docs/eip
- docs/elb
- docs/er
- docs/natgw
- docs/plas
- docs/vpc
@ -163,6 +164,7 @@
files:
- otc_doc_convertor/convertor.py
- docs/antiddos
- docs/dbss
- docs/iam
- docs/kms
- docs/waf