Skip to content

Commit 489f103

Browse files
committed
Reworded some documentation on selib tool
I reworded some of the documentation from the perspective of one who had not yet used the tool. Also made some minor changes to spelling.
1 parent ee5a7de commit 489f103

4 files changed

Lines changed: 48 additions & 47 deletions

File tree

src/SeleniumLibrary/__init__.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -550,16 +550,16 @@ class SeleniumLibrary(DynamicCore):
550550
551551
= Language =
552552
553-
SeleniumLibrary offers possibility to translte keyword names and documentation to new language. If language
553+
SeleniumLibrary offers the possibility to translate keyword names and documentation to new language. If language
554554
is defined, SeleniumLibrary will search from
555555
[https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#module-search-path | module search path]
556-
Python packages starting with `robotframework_seleniumlibrary_translation` by using
557-
[https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/ | Python pluging API]. Library
556+
for Python packages starting with `robotframework-seleniumlibrary-translation` by using the
557+
[https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/ | Python pluging API]. The Library
558558
is using naming convention to find Python plugins.
559559
560-
The package must implement single API call, ``get_language`` without any arguments. Method must return a
560+
The package must implement a single API call, ``get_language`` without any arguments. The method must return a
561561
dictionary containing two keys: ``language`` and ``path``. The language key value defines which language
562-
the package contains. Also value should match (case insentive) the library ``language`` import parameter.
562+
the package contains. Also the value should match (case insensitive) the library ``language`` import parameter.
563563
The path parameter value should be full path to the translation file.
564564
565565
== Translation file ==
@@ -568,8 +568,8 @@ class SeleniumLibrary(DynamicCore):
568568
format. The keys of json are the methods names, not the keyword names, which implements keywords. Value of
569569
key is json object which contains two keys: ``name`` and ``doc``. The ``name`` key contains the keyword
570570
translated name and `doc` contains translated documentation. Providing doc and name are optional, example
571-
translation json file can only provide translations to keyword names or only to documentatin. But it is
572-
always recomended to provide translation to both name and doc. Special key ``__intro__`` is for class level
571+
translation json file can only provide translations to keyword names or only to documentation. But it is
572+
always recommended to provide translation to both name and doc. Special key ``__intro__`` is for class level
573573
documentation and ``__init__`` is for init level documentation. These special values ``name`` can not be
574574
translated, instead ``name`` should be kept the same.
575575
@@ -580,9 +580,10 @@ class SeleniumLibrary(DynamicCore):
580580
languages, it only provides easy way to create full list keywords and their documentation in correct
581581
format. It is also possible to add keywords from library plugins by providing `--plugings` arguments
582582
to command. Example: `rfselib translation --plugings myplugin.SomePlugin /path/to/translation.json` The
583-
genered json file contains `sha256` key, which constains the sha256 sum of the library documentation,
584-
the sha256 sum is used by `rfselib translation --compare /path/to/translation.json` command, which compares
585-
transation to to library and prints outs a table which tell if there are changes needed for translation file.
583+
generated json file contains `sha256` key, which contains the sha256 sum of the library documentation.
584+
The sha256 sum is used by `rfselib translation --compare /path/to/translation.json` command, which compares
585+
the translation to the library and prints outs a table which tells if there are changes needed for
586+
translation file.
586587
587588
Example project for translation can be found from
588589
[https://github.com/MarketSquare/robotframework-seleniumlibrary-translation-fi | robotframework-seleniumlibrary-translation-fi]

src/SeleniumLibrary/entry/__main__.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16+
1617
import json
1718
from pathlib import Path
1819
from typing import Optional
1920
import click
2021

2122
from .get_versions import get_version
22-
from .translation import compare_translatoin, get_library_translaton
23+
from .translation import compare_translation, get_library_translation
2324

2425

2526
CONTEXT_SETTINGS = {"help_option_names": ["-h", "--help"]}
@@ -32,10 +33,9 @@ def cli():
3233
"""Robot Framework SeleniumLibrary command line tool.
3334
3435
Possible commands are:
35-
translation
3636
37-
38-
translation will generate detaul tranlsation json file from library keywords.
37+
translation
38+
will generate template translation json file from library keywords.
3939
4040
See each command argument help for more details what (optional) arguments that command supports.
4141
"""
@@ -49,7 +49,7 @@ def cli():
4949
required=True,
5050
)
5151
@click.option(
52-
"--plugings",
52+
"--plugin",
5353
help="Same as plugins argument in the library import.",
5454
default=None,
5555
type=str,
@@ -63,31 +63,31 @@ def cli():
6363
)
6464
def translation(
6565
filename: Path,
66-
plugings: Optional[str] = None,
66+
plugins: Optional[str] = None,
6767
compare: bool = False,
6868
):
6969
"""Default translation file from library keywords.
7070
7171
This will help users to create their own translation as Python plugins. Command
72-
will populate json file with english language. To create proper translation
72+
will populate json file with English language. To create proper translation
7373
file, users needs to translate the keyword name and doc arguments values in
7474
json file.
7575
7676
The filename argument will tell where the default json file is saved.
7777
78-
The --pluging argument is same as plugins argument in the library import.
79-
If you use plugins, it is also get default translation json file also witht
80-
the plugin keyword included in the library.
78+
The --plugin argument will add plugin keywords in addition to the library keywords
79+
into the default translation json file. It is used the same as plugins argument in
80+
the library import.
8181
8282
If the --compare flag is set, then command does not generate template
83-
translation file. Then it compares sha256 sums from the filenane
84-
to ones read from the library documenentation. It will print out a list
85-
of keywords which documentation sha256 does not match. This will ease
86-
translation projects to identify keywords which documentation needs updating.
83+
translation file. Instead it compares sha256 sums from the filename
84+
to the one read from the library documentation. It will print out a list
85+
of keywords for which the documentation sha256 does not match. This will ease
86+
translating projects to identify keywords which needs updating.
8787
"""
88-
translation = get_library_translaton(plugings)
88+
lib_translation = get_library_translation(plugins)
8989
if compare:
90-
if table := compare_translatoin(filename, translation):
90+
if table := compare_translation(filename, lib_translation):
9191
print(
9292
"Found differences between translation and library, see below for details."
9393
)

src/SeleniumLibrary/entry/translation.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
DOC_CHANGED = "Documentation update needed"
2525
NO_LIB_KEYWORD = "Keyword not found from library"
2626
MISSING_TRANSLATION = "Keyword is missing translation"
27-
MISSING_CHECKSUM = "Keyword tranlsaton is missing checksum"
27+
MISSING_CHECKSUM = "Keyword translation is missing checksum"
2828
MAX_REASON_LEN = max(
2929
len(DOC_CHANGED),
3030
len(NO_LIB_KEYWORD),
@@ -33,10 +33,10 @@
3333
)
3434

3535

36-
def get_library_translaton(plugings: Optional[str] = None) -> dict:
36+
def get_library_translation(plugins: Optional[str] = None) -> dict:
3737
from SeleniumLibrary import SeleniumLibrary
3838

39-
selib = SeleniumLibrary(plugins=plugings)
39+
selib = SeleniumLibrary(plugins=plugins)
4040
translation = {}
4141
for function in selib.attributes.values():
4242
translation[function.__name__] = {
@@ -57,18 +57,18 @@ def get_library_translaton(plugings: Optional[str] = None) -> dict:
5757
return translation
5858

5959

60-
def _max_kw_name_lenght(project_tanslation: dict) -> int:
60+
def _max_kw_name_length(project_translation: dict) -> int:
6161
max_lenght = 0
62-
for keyword_data in project_tanslation.values():
62+
for keyword_data in project_translation.values():
6363
if (current_kw_length := len(keyword_data["name"])) > max_lenght:
6464
max_lenght = current_kw_length
6565
return max_lenght
6666

6767

68-
def _get_heading(max_kw_lenght: int) -> List[str]:
68+
def _get_heading(max_kw_length: int) -> List[str]:
6969
heading = f"| {KEYWORD_NAME} "
7070
next_line = f"| {'-' * len(KEYWORD_NAME)}"
71-
if (padding := max_kw_lenght - len(KEYWORD_NAME)) > 0:
71+
if (padding := max_kw_length - len(KEYWORD_NAME)) > 0:
7272
heading = f"{heading}{' ' * padding}"
7373
next_line = f"{next_line}{'-' * padding}"
7474
reason = "Reason"
@@ -89,34 +89,34 @@ def _table_doc_updated(lib_kw: str, max_name_lenght: int, reason: str) -> str:
8989
return f"{line}|"
9090

9191

92-
def compare_translatoin(filename: Path, library_translation: dict):
92+
def compare_translation(filename: Path, library_translation: dict):
9393
with filename.open("r") as file:
9494
project_translation = json.load(file)
95-
max_kw_lenght = _max_kw_name_lenght(library_translation)
95+
max_kw_length = _max_kw_name_length(library_translation)
9696
table_body = []
9797
for lib_kw, lib_kw_data in library_translation.items():
9898
project_kw_data = project_translation.get(lib_kw)
9999
if not project_kw_data:
100100
table_body.append(
101-
_table_doc_updated(lib_kw, max_kw_lenght, MISSING_TRANSLATION)
101+
_table_doc_updated(lib_kw, max_kw_length, MISSING_TRANSLATION)
102102
)
103103
continue
104104
sha256_value = project_kw_data.get("sha256")
105105
if not sha256_value:
106106
table_body.append(
107-
_table_doc_updated(lib_kw, max_kw_lenght, MISSING_CHECKSUM)
107+
_table_doc_updated(lib_kw, max_kw_length, MISSING_CHECKSUM)
108108
)
109109
continue
110110
if project_kw_data["sha256"] != lib_kw_data["sha256"]:
111-
table_body.append(_table_doc_updated(lib_kw, max_kw_lenght, DOC_CHANGED))
111+
table_body.append(_table_doc_updated(lib_kw, max_kw_length, DOC_CHANGED))
112112
for project_kw in project_translation:
113113
if project_kw not in library_translation:
114114
table_body.append(
115-
_table_doc_updated(project_kw, max_kw_lenght, NO_LIB_KEYWORD)
115+
_table_doc_updated(project_kw, max_kw_length, NO_LIB_KEYWORD)
116116
)
117117
if not table_body:
118118
return []
119119

120-
table = _get_heading(max_kw_lenght)
120+
table = _get_heading(max_kw_length)
121121
table.extend(table_body)
122122
return table

utest/test/entry/test_entry_point.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
from SeleniumLibrary.entry.get_versions import get_version
88
from SeleniumLibrary.entry.translation import (
9-
compare_translatoin,
10-
get_library_translaton,
9+
compare_translation,
10+
get_library_translation,
1111
)
1212

1313

@@ -25,7 +25,7 @@ def test_version():
2525

2626

2727
def test_get_translation():
28-
data = get_library_translaton()
28+
data = get_library_translation()
2929
for item in data.values():
3030
assert item["name"], item["name"]
3131
assert item["doc"], item["doc"]
@@ -34,19 +34,19 @@ def test_get_translation():
3434

3535
def test_compare_translation(tmp_path: Path):
3636
translation = tmp_path / "translation.json"
37-
data = get_library_translaton()
37+
data = get_library_translation()
3838
with translation.open("w") as file:
3939
json.dump(data, file, indent=4)
40-
table = compare_translatoin(translation, data)
40+
table = compare_translation(translation, data)
4141
verify_all("No changes", table)
4242

4343

4444
def test_compare_translation_changes(tmp_path: Path):
4545
translation = tmp_path / "translation.json"
46-
data = get_library_translaton()
46+
data = get_library_translation()
4747
data.pop("handle_alert", None)
4848
data["alert_should_be_present"]["sha256"] = "foo"
4949
with translation.open("w") as file:
5050
json.dump(data, file, indent=4)
51-
table = compare_translatoin(translation, get_library_translaton())
51+
table = compare_translation(translation, get_library_translation())
5252
verify_all("Changes", table)

0 commit comments

Comments
 (0)