django-docs-viewer 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/PKG-INFO +2 -2
  2. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/README.md +1 -1
  3. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/pages.py +19 -9
  4. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/views.py +6 -4
  5. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/pyproject.toml +1 -1
  6. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/LICENSE +0 -0
  7. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/__init__.py +0 -0
  8. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/apps.py +0 -0
  9. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/conf.py +0 -0
  10. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/locale/de/LC_MESSAGES/django.mo +0 -0
  11. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/locale/de/LC_MESSAGES/django.po +0 -0
  12. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/locale/en/LC_MESSAGES/django.mo +0 -0
  13. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/locale/en/LC_MESSAGES/django.po +0 -0
  14. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/locale/fr/LC_MESSAGES/django.mo +0 -0
  15. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/locale/fr/LC_MESSAGES/django.po +0 -0
  16. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/navigation.py +0 -0
  17. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/paths.py +0 -0
  18. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/templates/docs_viewer/base.html +0 -0
  19. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/templates/docs_viewer/detail.html +0 -0
  20. {django_docs_viewer-0.2.0 → django_docs_viewer-0.2.2}/docs_viewer/urls.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: django-docs-viewer
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: A simple in-app Markdown documentation viewer for Django.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -52,7 +52,7 @@ no models — pages are read from disk and rendered on request.
52
52
 
53
53
  ## Features
54
54
 
55
- - Renders Markdown files (`fenced_code`, `tables`, `toc`, `sane_lists`).
55
+ - Renders Markdown files (`fenced_code`, `tables`, `toc`, `sane_lists`, `attr_list`).
56
56
  - Auto-generated sidebar navigation grouped by folder — or hand-written via a `menu.md` file.
57
57
  - Automatic per-page table of contents built from each page's headings.
58
58
  - Case-insensitive, traversal-safe URL resolution.
@@ -14,7 +14,7 @@ no models — pages are read from disk and rendered on request.
14
14
 
15
15
  ## Features
16
16
 
17
- - Renders Markdown files (`fenced_code`, `tables`, `toc`, `sane_lists`).
17
+ - Renders Markdown files (`fenced_code`, `tables`, `toc`, `sane_lists`, `attr_list`).
18
18
  - Auto-generated sidebar navigation grouped by folder — or hand-written via a `menu.md` file.
19
19
  - Automatic per-page table of contents built from each page's headings.
20
20
  - Case-insensitive, traversal-safe URL resolution.
@@ -7,14 +7,14 @@ import markdown
7
7
  from .conf import default_title, skip_dirs, toc_depth
8
8
  from .paths import docs_root
9
9
 
10
- MARKDOWN_EXTENSIONS = ["fenced_code", "tables", "toc", "sane_lists"]
10
+ MARKDOWN_EXTENSIONS = ["fenced_code", "tables", "toc", "sane_lists", "attr_list"]
11
11
 
12
12
  MENU_FILE = "menu.md"
13
13
  # Matched case-insensitively for the docs-root landing page; also lead each folder's navigation
14
14
  # group, ahead of the ordered pages. Kept lowercase and ordered by preference.
15
15
  INDEX_FILENAMES = ["index.md", "readme.md"]
16
16
 
17
- _HEADING_PATTERN = re.compile(r"^\s*#\s+(.+?)\s*$", re.MULTILINE)
17
+ _HEADING_PATTERN = re.compile(r"^\s*#\s+(.+?)(?:\s*\{:?[^}\n]*\})?\s*$", re.MULTILINE)
18
18
 
19
19
 
20
20
  def is_hidden(relative_path):
@@ -73,23 +73,33 @@ def discover_pages():
73
73
  return pages
74
74
 
75
75
 
76
- def dedicated_index():
77
- """The docs-root index/README landing file, matched case-insensitively; None when absent."""
78
- root = docs_root()
79
- if not root.is_dir():
76
+ def directory_index(directory):
77
+ """The index/README file directly inside directory, matched case-insensitively; None when absent."""
78
+ if directory is None or not directory.is_dir():
80
79
  return None
81
- by_name = {child.name.lower(): child.name for child in root.iterdir() if child.is_file()}
80
+ by_name = {child.name.lower(): child.name for child in directory.iterdir() if child.is_file()}
82
81
  for candidate in INDEX_FILENAMES:
83
82
  if candidate in by_name:
84
- return by_name[candidate]
83
+ return directory / by_name[candidate]
85
84
  return None
86
85
 
87
86
 
87
+ def dedicated_index():
88
+ """The docs-root index/README landing file name, matched case-insensitively; None when absent."""
89
+ match = directory_index(docs_root())
90
+ return match.name if match else None
91
+
92
+
93
+ def _landing_sort_key(page):
94
+ relative = page.relative_to(docs_root()).as_posix()
95
+ return (0 if is_index_filename(page.name) else 1, relative.lower())
96
+
97
+
88
98
  def landing_relative_path():
89
99
  index = dedicated_index()
90
100
  if index is not None:
91
101
  return index
92
- pages = discover_pages()
102
+ pages = sorted(discover_pages(), key=_landing_sort_key)
93
103
  return pages[0].relative_to(docs_root()).as_posix() if pages else None
94
104
 
95
105
 
@@ -6,7 +6,7 @@ from django.views.static import serve
6
6
 
7
7
  from .conf import base_template, login_required
8
8
  from .navigation import build_sidebar_html
9
- from .pages import is_hidden, landing_relative_path, render_page, site_title
9
+ from .pages import directory_index, is_hidden, landing_relative_path, render_page, site_title
10
10
  from .paths import (
11
11
  docs_root,
12
12
  is_image_request,
@@ -33,11 +33,13 @@ class DocsView(View):
33
33
  relative_path = landing_relative_path()
34
34
  if relative_path is None:
35
35
  raise Http404("No documentation available")
36
+ markdown_path = resolve_within_docs(relative_path)
36
37
  else:
37
- # An optional .md suffix lets relative links between Markdown pages resolve to a sibling page.
38
- relative_path = with_markdown_suffix(doc_path)
38
+ markdown_path = resolve_within_docs(with_markdown_suffix(doc_path))
39
+ if markdown_path is None or not markdown_path.is_file():
40
+ directory = resolve_within_docs(without_markdown_suffix(doc_path))
41
+ markdown_path = directory_index(directory)
39
42
 
40
- markdown_path = resolve_within_docs(relative_path)
41
43
  if markdown_path is None or not markdown_path.is_file():
42
44
  raise Http404("Documentation page not found")
43
45
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "django-docs-viewer"
3
- version = "0.2.0"
3
+ version = "0.2.2"
4
4
  description = "A simple in-app Markdown documentation viewer for Django."
5
5
  authors = [{ name = "Malte Gerth", email = "mail@malte-gerth.de" }]
6
6
  license = "MIT"