Skip to content

Commit 1dcbc8c

Browse files
authored
Merge pull request #90 from UBC-MDS/prettier-docs
Enhance documentation
2 parents 980bd35 + 7104e7c commit 1dcbc8c

File tree

8 files changed

+81
-37
lines changed

8 files changed

+81
-37
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,17 @@ All notable changes to this project will be documented in this file.
5858
- Removed unused `docs` directory and Sphinx configuration
5959
- Removed unused GitHub Actions workflows
6060
- Removed Sphinx-related dependencies from `pyproject.toml`
61+
62+
## [3.0.0] - 2026-02-02
63+
64+
- Fixed errors when running examples in `README.md` and docstrings (with many thanks to the peer review)
65+
- Added step-by-step tutorials to `README.md` and documentation site (with many thanks to the peer review)
66+
- Added `CHANGELOG.md` to the documentation site
67+
- Added badges to `README.md` for PyPI version, build status, code quality, and documentation status
68+
- Added more words to `minidict` dataset
69+
- Added more in-line comments to user functions (with many thanks to the peer review)
70+
- Added work organization and retrospectives to `CONTRIBUTING.md`
71+
- Added GitHub Actions workflow for dynamic versioning
72+
- Added GitHub Actions workflow for previewing documentation site
73+
- Added GitHub Actions workflow for code coverage reporting
74+
- Removed redundant signs in the example code snippets in `README.md` (with many thanks to the peer review)

README.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,40 @@ You can install this package into your preferred Python environment using pip:
2828

2929
```bash
3030
pip install -i https://test.pypi.org/simple/ wordguess
31-
``````
31+
```
32+
33+
To use `wordguess` in your code, you can follow this full example that applies the built-in `minidict` dataset and all four main functions:
34+
35+
```python
36+
# 1. Load the package with alias.
37+
import wordguess as wg
38+
```
3239

33-
To use `wordguess` in your code:
40+
```python
41+
# 2. Get the string results of making three different guesses against the target "major".
42+
result_hist = {}
43+
for word in ['whelp','might','madam']:
44+
# As a player, we do not know the target word "major",
45+
# so we simulate getting the result:
46+
result_hist[word] = wg.get_result('major', word)
47+
```
48+
49+
```python
50+
# 3. Get the top three possible target words based on the result history.
51+
# This may be used to provide hints to the player.
52+
wg.get_n_guesses(result_hist, n=3)
53+
```
3454

3555
```python
36-
>>> from wordguess.get_result import get_result
37-
>>> get_result("spark", "spoon")
56+
# 4. Get the overall score of guesses based on the results:
57+
results = list(result_hist.values())
58+
wg.get_score(results)
3859
```
3960

4061
```python
41-
>>> import wordguess as wg
42-
>>>
43-
>>> result_hist = {}
44-
>>> for word in ['whelp','might','madam']:
45-
>>> result_hist[word] = wg.get_result('major', word)
46-
>>> wg.get_n_guesses(result_hist, n=10)
62+
# 5. Convert the result of the last guess into a human-readable pattern.
63+
last_result = result_hist['madam']
64+
wg.result_to_pattern(last_result)
4765
```
4866

4967
## Development

_quarto.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ project:
55
- LICENSE
66
- CODE_OF_CONDUCT.md
77
- CONTRIBUTING.md
8+
- CHANGELOG.md
89
- README.md
910

1011
website:
@@ -35,6 +36,8 @@ website:
3536
href: index.qmd
3637
- text: "API Reference"
3738
href: reference/index.qmd
39+
- text: "Changelog"
40+
href: CHANGELOG.md
3841
- text: "Contributing Guide"
3942
href: CONTRIBUTING.md
4043
- text: "Code of Conduct"

src/wordguess/_internals.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@
566566
"harry",
567567
"sweep",
568568
"manor",
569+
"slope",
569570
"guild",
570571
"foray",
571572
"altar",
@@ -635,5 +636,7 @@
635636
"exult",
636637
"candy",
637638
"might",
638-
"spark"
639+
"spark",
640+
"apply",
641+
"stare"
639642
]

src/wordguess/get_n_guesses.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def get_n_guesses(result_hist: dict, n: int = None, corpus: list = minidict) ->
116116
This function filters the given corpus of allowed words using the information
117117
contained in a result history. Each entry in the result history consists of
118118
a guessed word and its corresponding result string, where:
119+
119120
- '0' indicates the letter is not present in the target word,
120121
- '1' indicates the letter is present but in the wrong position, and
121122
- '2' indicates the letter is correct and in the correct position.
@@ -130,22 +131,23 @@ def get_n_guesses(result_hist: dict, n: int = None, corpus: list = minidict) ->
130131
result_hist : dict
131132
A dictionary mapping previously guessed words to their
132133
corresponding result strings composed of '0', '1', and '2'.
133-
n : int (optional)
134+
n : int, optional
134135
The maximum number of valid guesses to return.
135136
If None, all valid guesses are returned.
136-
corpus : list (optional)
137+
corpus : list, optional
137138
A list of all allowed words to consider as possible targets.
138139
139140
Returns
140141
-------
141-
list: A list of words from the corpus that are consistent with the result history.
142+
list
143+
A list of words from the corpus that are consistent with the result history.
142144
143145
Raises
144146
------
145147
TypeError
146-
If result_hist is not a dictionary.
147-
If n is not a positive integer or None.
148-
If corpus is not a list of strings.
148+
If result_hist is not a dictionary;
149+
if n is not a positive integer or None; or
150+
if corpus is not a list of strings.
149151
ValueError
150152
If result_hist is internally inconsistent.
151153
@@ -158,7 +160,6 @@ def get_n_guesses(result_hist: dict, n: int = None, corpus: list = minidict) ->
158160
>>> result_hist = {"crane": "01200", "sloth": "10020"}
159161
>>> get_n_guesses(result_hist, corpus=corpus)
160162
['about', 'shout', 'mount']
161-
162163
>>> get_n_guesses(result_hist, n=2, corpus=corpus)
163164
['shout', 'mount']
164165
"""

src/wordguess/get_result.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,28 @@ def get_result(target: str, guess: str, corpus: list = minidict) -> str:
1111
The secret word that needs to be guessed.
1212
guess : str
1313
The word provided by the player to be compared against the target.
14-
corpus : list (optional)
14+
corpus : list, optional
1515
A collection of valid words used for validation.
1616
Defaults to `minidict`.
1717
1818
Returns
1919
-------
2020
str
21-
A string of digits representing the result for each letter:
22-
- '0' : The letter does not exist in the target.
23-
- '1' : The letter exists in the target but in a different position.
24-
- '2' : The letter is in the correct position.
21+
A string of digits representing the result for each letter, containing '0', '1', and '2'.
2522
2623
Raises
2724
------
2825
TypeError
2926
If target or guess are not strings.
3027
ValueError
31-
If target and guess have different lengths.
32-
If the target is not found in the corpus.
33-
If the guess is not found in the corpus.
28+
If target and guess have different lengths;
29+
if the target is not found in the corpus; or
30+
if the guess is not found in the corpus.
31+
32+
See Also
33+
--------
34+
get_n_guesses : A function that generates a list of possible valid guesses based on previous results.
35+
3436
Examples
3537
--------
3638
>>> get_result("apple", "apply")

src/wordguess/get_score.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def get_score(
2424
2525
Parameters
2626
----------
27-
result : list of str
27+
result : list
2828
A list containing the list of result. The result is a string
2929
with characters '0', '1', and '2' representing different guess outcomes.
3030
@@ -46,9 +46,9 @@ def get_score(
4646
TypeError
4747
If result is not a list of strings or penalty is not a boolean.
4848
ValueError
49-
If result strings contain invalid characters.
50-
If result strings do not have the same length.
51-
If any result string is empty.
49+
If result strings contain invalid characters;
50+
if result strings do not have the same length; or
51+
if any result string is empty.
5252
5353
Examples
5454
--------

src/wordguess/result_to_pattern.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ def result_to_pattern(result: str) -> str:
22
"""
33
Convert a result string to a human-readable pattern of symbols.
44
5-
This function maps each character in a result string to a corresponding colored square
6-
symbol.
5+
This function maps each character in a result string to a corresponding colored square symbol.
6+
77
- The character '0' maps to a dark grey square symbol,
88
- The character '1' maps to a yellow square symbol and,
99
- The character '2' maps to a green square symbol.
10+
1011
The output is a string composed of UTF-8 colored square symbols.
1112
1213
Parameters
@@ -16,7 +17,8 @@ def result_to_pattern(result: str) -> str:
1617
1718
Returns
1819
-------
19-
str: The corresponding human-readable string pattern composed of UTF-8 colored symbols.
20+
str
21+
The corresponding human-readable string pattern composed of UTF-8 colored symbols.
2022
2123
Raises
2224
------
@@ -27,13 +29,14 @@ def result_to_pattern(result: str) -> str:
2729
2830
See Also
2931
--------
30-
get_result : A function that generate the result string for a given guess against a target word.
32+
get_result : A function that generates the result string for a given guess against a target word.
3133
32-
Example:
34+
Examples
35+
--------
3336
>>> result_to_pattern("01102")
34-
"⬛🟨🟨⬛🟩"
37+
'⬛🟨🟨⬛🟩'
3538
>>> result_to_pattern("0001221")
36-
"⬛⬛⬛🟨🟩🟩🟨"
39+
'⬛⬛⬛🟨🟩🟩🟨'
3740
"""
3841
if not isinstance(result, str): # checks that input is of `str` type
3942
raise TypeError(f"Expected the input to be of type str, got {type(result)}")

0 commit comments

Comments
 (0)