mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 16:25:00 +00:00
style: apply linter formatting changes
This commit is contained in:
parent
671f3078c1
commit
9e0a9e919b
2 changed files with 39 additions and 24 deletions
|
@ -57,24 +57,24 @@ def fname_to_url(filepath):
|
||||||
return "" # 'website' not found in the path
|
return "" # 'website' not found in the path
|
||||||
|
|
||||||
# Extract the part of the path starting from 'website'
|
# Extract the part of the path starting from 'website'
|
||||||
relevant_parts = parts[website_index + 1:]
|
relevant_parts = parts[website_index + 1 :]
|
||||||
|
|
||||||
# Handle _includes directory
|
# Handle _includes directory
|
||||||
if relevant_parts and relevant_parts[0] == "_includes":
|
if relevant_parts and relevant_parts[0] == "_includes":
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
# Join the remaining parts
|
# Join the remaining parts
|
||||||
url_path = '/'.join(relevant_parts)
|
url_path = "/".join(relevant_parts)
|
||||||
|
|
||||||
# Handle index.md and other .md files
|
# Handle index.md and other .md files
|
||||||
if url_path.endswith(index):
|
if url_path.endswith(index):
|
||||||
url_path = url_path[:-len(index)]
|
url_path = url_path[: -len(index)]
|
||||||
elif url_path.endswith(md):
|
elif url_path.endswith(md):
|
||||||
url_path = url_path[:-len(md)] + ".html"
|
url_path = url_path[: -len(md)] + ".html"
|
||||||
|
|
||||||
# Ensure the URL starts and ends with '/'
|
# Ensure the URL starts and ends with '/'
|
||||||
url_path = url_path.strip('/')
|
url_path = url_path.strip("/")
|
||||||
|
|
||||||
return f"https://aider.chat/{url_path}"
|
return f"https://aider.chat/{url_path}"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import unittest
|
|
||||||
from unittest.mock import MagicMock
|
|
||||||
import os
|
import os
|
||||||
|
import unittest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import aider
|
import aider
|
||||||
from aider.coders import Coder
|
from aider.coders import Coder
|
||||||
|
@ -58,36 +58,51 @@ class TestHelp(unittest.TestCase):
|
||||||
|
|
||||||
def test_fname_to_url_unix(self):
|
def test_fname_to_url_unix(self):
|
||||||
# Test relative Unix-style paths
|
# Test relative Unix-style paths
|
||||||
self.assertEqual(fname_to_url('website/docs/index.md'), 'https://aider.chat/docs/')
|
self.assertEqual(fname_to_url("website/docs/index.md"), "https://aider.chat/docs/")
|
||||||
self.assertEqual(fname_to_url('website/docs/usage.md'), 'https://aider.chat/docs/usage.html')
|
self.assertEqual(
|
||||||
self.assertEqual(fname_to_url('website/_includes/header.md'), '')
|
fname_to_url("website/docs/usage.md"), "https://aider.chat/docs/usage.html"
|
||||||
|
)
|
||||||
|
self.assertEqual(fname_to_url("website/_includes/header.md"), "")
|
||||||
|
|
||||||
# Test absolute Unix-style paths
|
# Test absolute Unix-style paths
|
||||||
self.assertEqual(fname_to_url('/home/user/project/website/docs/index.md'), 'https://aider.chat/docs/')
|
self.assertEqual(
|
||||||
self.assertEqual(fname_to_url('/home/user/project/website/docs/usage.md'), 'https://aider.chat/docs/usage.html')
|
fname_to_url("/home/user/project/website/docs/index.md"), "https://aider.chat/docs/"
|
||||||
self.assertEqual(fname_to_url('/home/user/project/website/_includes/header.md'), '')
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
fname_to_url("/home/user/project/website/docs/usage.md"),
|
||||||
|
"https://aider.chat/docs/usage.html",
|
||||||
|
)
|
||||||
|
self.assertEqual(fname_to_url("/home/user/project/website/_includes/header.md"), "")
|
||||||
|
|
||||||
def test_fname_to_url_windows(self):
|
def test_fname_to_url_windows(self):
|
||||||
# Test relative Windows-style paths
|
# Test relative Windows-style paths
|
||||||
self.assertEqual(fname_to_url(r'website\docs\index.md'), 'https://aider.chat/docs/')
|
self.assertEqual(fname_to_url(r"website\docs\index.md"), "https://aider.chat/docs/")
|
||||||
self.assertEqual(fname_to_url(r'website\docs\usage.md'), 'https://aider.chat/docs/usage.html')
|
self.assertEqual(
|
||||||
self.assertEqual(fname_to_url(r'website\_includes\header.md'), '')
|
fname_to_url(r"website\docs\usage.md"), "https://aider.chat/docs/usage.html"
|
||||||
|
)
|
||||||
|
self.assertEqual(fname_to_url(r"website\_includes\header.md"), "")
|
||||||
|
|
||||||
# Test absolute Windows-style paths
|
# Test absolute Windows-style paths
|
||||||
self.assertEqual(fname_to_url(r'C:\Users\user\project\website\docs\index.md'), 'https://aider.chat/docs/')
|
self.assertEqual(
|
||||||
self.assertEqual(fname_to_url(r'C:\Users\user\project\website\docs\usage.md'), 'https://aider.chat/docs/usage.html')
|
fname_to_url(r"C:\Users\user\project\website\docs\index.md"), "https://aider.chat/docs/"
|
||||||
self.assertEqual(fname_to_url(r'C:\Users\user\project\website\_includes\header.md'), '')
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
fname_to_url(r"C:\Users\user\project\website\docs\usage.md"),
|
||||||
|
"https://aider.chat/docs/usage.html",
|
||||||
|
)
|
||||||
|
self.assertEqual(fname_to_url(r"C:\Users\user\project\website\_includes\header.md"), "")
|
||||||
|
|
||||||
def test_fname_to_url_edge_cases(self):
|
def test_fname_to_url_edge_cases(self):
|
||||||
# Test paths that don't contain 'website'
|
# Test paths that don't contain 'website'
|
||||||
self.assertEqual(fname_to_url('/home/user/project/docs/index.md'), '')
|
self.assertEqual(fname_to_url("/home/user/project/docs/index.md"), "")
|
||||||
self.assertEqual(fname_to_url(r'C:\Users\user\project\docs\index.md'), '')
|
self.assertEqual(fname_to_url(r"C:\Users\user\project\docs\index.md"), "")
|
||||||
|
|
||||||
# Test empty path
|
# Test empty path
|
||||||
self.assertEqual(fname_to_url(''), '')
|
self.assertEqual(fname_to_url(""), "")
|
||||||
|
|
||||||
# Test path with 'website' in the wrong place
|
# Test path with 'website' in the wrong place
|
||||||
self.assertEqual(fname_to_url('/home/user/website_project/docs/index.md'), '')
|
self.assertEqual(fname_to_url("/home/user/website_project/docs/index.md"), "")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue