Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: review and refactor package #37

Merged
merged 34 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4914e33
MAINT: rework directives into exercise and solution directives
mmcky Oct 28, 2021
5ac852e
simplify and reduce repeated code
mmcky Oct 28, 2021
4ddd56f
split post_transforms and review
mmcky Oct 29, 2021
f176cb7
introduce LaTeX markup object
mmcky Oct 29, 2021
dc66d0d
reorg nodes.py
mmcky Oct 29, 2021
ca24235
remove functions not required
mmcky Oct 29, 2021
cc835a7
odds and end updates commit before references refactor
mmcky Oct 29, 2021
a3338bf
REF: rework reference post-transforms, in work
mmcky Nov 1, 2021
6fbdeff
Merge branch 'master' into refactor-oct2021
mmcky Nov 1, 2021
8e70340
TST: Updating test solutions for test_exercise
mmcky Nov 2, 2021
5b91146
REFACTOR: update exercise nodes, directives, and post_transforms with…
mmcky Nov 16, 2021
945a322
rework references resolution
mmcky Nov 18, 2021
1eaa9b8
rework references resolution
mmcky Nov 18, 2021
962de98
update fixtures for final review
mmcky Nov 19, 2021
84a3d2a
fixes for updating references
mmcky Nov 22, 2021
ebf67f5
retain parent data when reseting title nodes in exercise and solution…
mmcky Nov 24, 2021
56a96c5
latex styling for exercise and solution titles
AakashGfude Nov 24, 2021
087c967
update LaTeX fixtures
mmcky Nov 24, 2021
1665d17
[rework] Reworked references (round 2) to simplify
mmcky Nov 25, 2021
62a94b2
Reorganise tests
mmcky Nov 26, 2021
16d4ae0
style update for custom titles, ensure mathjax loading if math in tit…
mmcky Nov 29, 2021
8d0d969
adding in empty title for enumerated exercise cells for LaTeX
mmcky Nov 29, 2021
1daa7a7
resolve exercise titles for enumerated nodes when targeting latex
mmcky Nov 29, 2021
20b26d9
Fix LaTeX issue with reference resolution
mmcky Nov 30, 2021
3b9635f
[LaTeX] fix reference resolution for solutions
mmcky Nov 30, 2021
b6520fe
tidy up code and remove unecessary methods
mmcky Nov 30, 2021
cd044bb
docs review
mmcky Nov 30, 2021
a41e286
minor update to docs
mmcky Nov 30, 2021
fc158cb
removing unused functions and unused latex handling
AakashGfude Dec 1, 2021
5664626
final code review
mmcky Dec 5, 2021
f6907ab
update docs with developer notes
mmcky Dec 6, 2021
e3686be
change to EBP developers
mmcky Dec 6, 2021
94fa543
additional final edits of docstrings
mmcky Dec 6, 2021
02d8eff
FIX: fix solution node titles are links to exercise node
mmcky Dec 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ exclude: >
\.vscode/settings\.json|
docs/source/conf\.py|
tests/test_exercise/.*|
tests/test_exercise_references/.*|
tests/test_solution/.*|
tests/test_solution_references/.*|
tests/test_hiddendirective/.*|
)$

Expand Down
8 changes: 4 additions & 4 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ for producing exercise and solution directives, for html and pdf outputs.

**Features**:

The **exercise** directive is
The **exercise** directive is:

1. automatically numbered
2. supports options such as `class`, `label`, `nonumber`, and `hidden`
3. can easily be referenced through `ref` and `numref` roles
3. can be referenced through `ref` and `numref` roles

The **solution** directive

Expand All @@ -37,7 +37,7 @@ The **solution** directive
To get started with `sphinx-exercise`, first install it through `pip`:

```bash
pip install -e.
pip install sphinx-exercise
```

### Jupyter-Book Project
Expand All @@ -50,7 +50,7 @@ sphinx:
- sphinx_exercise
```

you may then use `jb build <project>` and the extension will be used by your `JupyterBook` project.
you may then use `jb build <project>` and the extension will be used by your `Jupyter Book` project.

### Sphinx Project

Expand Down
17 changes: 10 additions & 7 deletions docs/source/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,26 @@ _Source:_ [QuantEcon](https://python-programming.quantecon.org/functions.html#Ex

### Referencing Exercises

You can refer to an exercise using the `{ref}` role like ```{ref}`my-exercise` ```, which will display the title of the exercise directive. In the event that directive does not have a title, the title will default to "Exercise" like so: {ref}`my-exercise`.
You can refer to an exercise using the `{ref}` role like ```{ref}`my-exercise` ```, which will display the title of the exercise directive. In the event that directive does not have a title, the title will be the default "Exercise" or "Exercise {number}" like so: {ref}`my-exercise`.

Enumerable directives can also be referenced through the `numref` role like ```{numref}`my-exercise` ```, which will display the number of the exercise directive. Referencing the above directive will display {numref}`my-exercise`. Furthermore, `numref` can take in three additional placeholders: _%s_ and _{number}_ which get replaced by the exercise number and _name_ by the exercise title.[^note]
Enumerable directives can also be referenced through the `numref` role like ```{numref}`my-exercise` ```, which will display the number of the exercise directive. Referencing the above directive will display {numref}`my-exercise`. In this case it displays the same result as the `{ref}` role as `exerise` notes are (by default) enumerated.

Furthermore, `numref` can take in three additional placeholders for more customized titles:

1. _%s_
2. _{number}_ which get replaced by the exercise number, and
3. _{name}_ by the exercise title.[^note]

<!-- You can refer to an exercise using the `{ref}` role like: ```{ref}`my-exercise` ```, which will replace the reference with the exercise number like so: {ref}`my-exercise`. When an explicit text is provided, this caption will serve as the title of the reference. -->
An example ```{numref}`My custom {number} title and {name}` ``` would resolve to {numref}`My custom {number} title and {name} <my-exercise>`

[^note]: If the exercise directive does not have a title, an `invalid numfig format` warning will be displayed during build if the user tries to use the _{name}_ placeholder.


## Solution Directive

A solution directive can be included using the `solution` pattern. It takes in the label of the directive it wants to link to as a required argument. Unlike the `exercise` directive, the solution directive is unenumerable. The following options are also supported:
A solution directive can be included using the `solution` pattern. It takes in the label of the directive it wants to link to as a required argument. Unlike the `exercise` directive, the solution directive not enumerable as it inherits directly from the linked exercise.

The following options are also supported:

* `label` : text

Expand All @@ -83,9 +89,6 @@ A solution directive can be included using the `solution` pattern. It takes in t

Removes the directive from the final output.

```{note}
The title of the solution directive links directly to the referred directive.
```

**Example**

Expand Down
Loading