Skip to content

Commit

Permalink
docs: fix relative links & span_getter args
Browse files Browse the repository at this point in the history
  • Loading branch information
percevalw committed Sep 13, 2023
1 parent 6deb57a commit a1fb579
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 11 deletions.
21 changes: 21 additions & 0 deletions docs/scripts/plugin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import os
import re
from pathlib import Path

import mkdocs.config
import mkdocs.plugins
import mkdocs.structure
import mkdocs.structure.files
import mkdocs.structure.nav
import mkdocs.structure.pages


def exclude_file(name):
Expand Down Expand Up @@ -118,3 +121,21 @@ def on_page_read_source(page, config):
if page.file.src_path in VIRTUAL_FILES:
return VIRTUAL_FILES[page.file.src_path]
return None


@mkdocs.plugins.event_priority(-1000)
def on_page_content(
html: str,
page: mkdocs.structure.pages.Page,
config: mkdocs.config.Config,
files: mkdocs.structure.files.Files,
):
def replace_link(match):
relative_url = url = match.group(1)
page_url = os.path.join("/", page.file.url)
if url.startswith("/"):
relative_url = os.path.relpath(url, page_url)
return f'href="{relative_url}"'

# Replace absolute paths with path relative to the rendered page
return re.sub(r'href="([^"]*)"', replace_link, html)
3 changes: 1 addition & 2 deletions edsnlp/pipelines/qualifiers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class RuleBasedQualifier(BaseComponent):
a string with the value "TEXT" or "NORM", or a dict with the key 'term_attr'
we can also add a key for each regex.
span_getter : SpanGetterArg
Where to look for dates in the doc. By default, look in the whole doc. You can
combine this with the `merge_mode` argument for interesting results.
Which entities should be classified. By default, `doc.ents`
on_ents_only : Union[bool, str, List[str], Set[str]]
Whether to look for matches around detected entities only.
Useful for faster inference in downstream tasks.
Expand Down
3 changes: 1 addition & 2 deletions edsnlp/pipelines/qualifiers/family/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ class FamilyContextQualifier(RuleBasedQualifier):
termination : Optional[List[str]]
List of syntagms termination terms.
span_getter : SpanGetterArg
Where to look for dates in the doc. By default, look in the whole doc. You can
combine this with the `merge_mode` argument for interesting results.
Which entities should be classified. By default, `doc.ents`
on_ents_only : Union[bool, str, List[str], Set[str]]
Deprecated, use `span_getter` instead.
Expand Down
3 changes: 1 addition & 2 deletions edsnlp/pipelines/qualifiers/history/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ class HistoryQualifier(RuleBasedQualifier):
closest_dates_only : bool
Whether to include the closest dates only.
span_getter : SpanGetterArg
Where to look for dates in the doc. By default, look in the whole doc. You can
combine this with the `merge_mode` argument for interesting results.
Which entities should be classified. By default, `doc.ents`
on_ents_only : Union[bool, str, List[str], Set[str]]
Deprecated, use `span_getter` instead.
Expand Down
3 changes: 2 additions & 1 deletion edsnlp/pipelines/qualifiers/hypothesis/hypothesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ class HypothesisQualifier(RuleBasedQualifier):
attr : str
spaCy's attribute to use:
a string with the value "TEXT" or "NORM", or a dict with the key 'term_attr'
we can also add a key for each regex.
span_getter : SpanGetterArg
Which entities should be classified. By default, `doc.ents`
on_ents_only : Union[bool, str, List[str], Set[str]]
Deprecated, use `span_getter` instead.
Expand Down
3 changes: 1 addition & 2 deletions edsnlp/pipelines/qualifiers/negation/negation.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ class NegationQualifier(RuleBasedQualifier):
termination : Optional[List[str]]
List of termination terms.
span_getter : SpanGetterArg
Where to look for dates in the doc. By default, look in the whole doc. You can
combine this with the `merge_mode` argument for interesting results.
Which entities should be classified. By default, `doc.ents`
on_ents_only : Union[bool, str, List[str], Set[str]]
Deprecated, use `span_getter` instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class ReportedSpeechQualifier(RuleBasedQualifier):
a string with the value "TEXT" or "NORM",
or a dict with the key 'term_attr'
we can also add a key for each regex.
span_getter : SpanGetterArg
Which entities should be classified. By default, `doc.ents`
on_ents_only : Union[bool, str, List[str], Set[str]]
Whether to look for matches around detected entities only.
Useful for faster inference in downstream tasks.
Expand Down
1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ plugins:
show_root_toc_entry: false
show_signature: false
merge_init_into_class: true
- autolinks
- bibtex:
bibtex_file: "docs/references.bib"
# Just uncomment the following lines to enable i18n
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ dev = [
"mkdocs~=1.5.2",
"mkdocstrings~=0.20",
"mkdocstrings-python~=1.1",
"mkdocs-autolinks-plugin~=0.7.1",
"pybtex~=0.24.0",
"pathspec>=0.11.1", # required by vendored mkdocs-autorefs PR
"astunparse",
Expand Down

0 comments on commit a1fb579

Please sign in to comment.