@@ -2,9 +2,9 @@ Implementing hooks and writing internal plugins
22***********************************************
33Implementing a hook is fairly simple, and works the same way regardless of what
44type of hook it is (core or extension). If you are working with your own fork
5- of `` repobee `` , all you have to do is write a small module implementing some hooks,
5+ of RepoBee , all you have to do is write a small module implementing some hooks,
66and drop it into the ``repobee.ext `` sub-package (i.e. the in directory
7- ``repobee/ext `` in the `` repobee `` repo).
7+ ``repobee/ext `` in the RepoBee repo).
88
99There are two ways to implement hooks: as standalone functions or wrapped in a
1010class. In the following two sections, we'll implement the
@@ -16,7 +16,7 @@ Hook functions in a plugin class
1616================================
1717Wrapping hook implementations in a class inheriting from
1818:py:class: `~repobee_plug.pluginmeta.Plugin ` is the recommended way to write
19- plugins for `` repobee `` . The class does some checks to make sure that all
19+ plugins for RepoBee . The class does some checks to make sure that all
2020public functions have hook function names, which comes in handy if you are
2121in the habit of misspelling stuff (aren't we all?). Doing it this way,
2222``exampleplug.py `` would look like this:
@@ -35,12 +35,14 @@ in the habit of misspelling stuff (aren't we all?). Doing it this way,
3535 class ExamplePlugin (plug .Plugin ):
3636 """ Example plugin that implements the act_on_cloned_repo hook."""
3737
38- def act_on_cloned_repo (self ,
39- path : Union[str , pathlib.Path]) -> plug.HookResult:
38+ def act_on_cloned_repo (
39+ self , path : Union[str , pathlib.Path], api ,
40+ ) -> plug.HookResult:
4041 """ Do something with a cloned repo.
4142
4243 Args:
4344 path: Path to the student repo.
45+ api: A platform API instance.
4446 Returns:
4547 a plug.HookResult specifying the outcome.
4648 """
@@ -59,8 +61,8 @@ fact, all public methods in a class deriving from
5961:py:class: `~repobee_plug.pluginmeta.Plugin ` must have names of hook functions,
6062or the class will fail to be created. You can see that the hook returns a
6163:py:class: `~repobee_plug.util.HookResult `. This is used for reporting the
62- results in `` repobee `` , and is entirely optional (not all hooks support it,
63- though). Do note that if ``None `` is returned instead, `` repobee `` will not
64+ results in RepoBee , and is entirely optional (not all hooks support it,
65+ though). Do note that if ``None `` is returned instead, RepoBee will not
6466report anything for the hook. It is recommended that hooks that can return
6567``HookResult `` do. For a comprehensive example of an internal plugin
6668implemented with a class, see the built-in `javac plugin `_.
0 commit comments