From f937d2f3081cc9a350b5beaa3f07f05a627a0bc9 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 18 Apr 2021 23:42:15 +0200 Subject: [PATCH] Adding documentations to the repository interface --- .github/workflows/build.yml | 4 +- Kyoo.Common/Controllers/IRepository.cs | 46 +++++++++++++++++++ .../Implementations/LibraryManager.cs | 4 ++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5969ea76..bd06596b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,8 +21,8 @@ jobs: artifact: macos steps: - uses: actions/checkout@v1 - - name: Checkout submodules - run: git submodule update --init --recursive + with: + submodules: recursive - name: Setup .NET uses: actions/setup-dotnet@v1 with: diff --git a/Kyoo.Common/Controllers/IRepository.cs b/Kyoo.Common/Controllers/IRepository.cs index 1caccfc5..bffe844e 100644 --- a/Kyoo.Common/Controllers/IRepository.cs +++ b/Kyoo.Common/Controllers/IRepository.cs @@ -9,25 +9,60 @@ using Kyoo.Models; namespace Kyoo.Controllers { + /// + /// Informations about the pagination. How many items should be displayed and where to start. + /// public readonly struct Pagination { + /// + /// The count of items to return. + /// public int Count { get; } + /// + /// Where to start? Using the given sort + /// public int AfterID { get; } + /// + /// Create a new instance. + /// + /// Set the value + /// Set the value. If not specified, it will start from the start public Pagination(int count, int afterID = 0) { Count = count; AfterID = afterID; } + /// + /// Implicitly create a new pagination from a limit number. + /// + /// Set the value + /// A new instance public static implicit operator Pagination(int limit) => new(limit); } + /// + /// Informations about how a query should be sorted. What factor should decide the sort and in which order. + /// + /// For witch type this sort applies public readonly struct Sort { + /// + /// The sort key. This member will be used to sort the results. + /// public Expression> Key { get; } + /// + /// If this is set to true, items will be sorted in descend order else, they will be sorted in ascendent order. + /// public bool Descendant { get; } + /// + /// Create a new instance. + /// + /// The sort key given. It is assigned to . + /// Should this be in descendant order? The default is false. + /// If the given key is not a member. public Sort(Expression> key, bool descendant = false) { Key = key; @@ -37,6 +72,11 @@ namespace Kyoo.Controllers throw new ArgumentException("The given sort key is not valid."); } + /// + /// Create a new instance from a key's name (case insensitive). + /// + /// A key name with an optional order specifier. Format: "key:asc", "key:desc" or "key". + /// An invalid key or sort specifier as been given. public Sort(string sortBy) { if (string.IsNullOrEmpty(sortBy)) @@ -65,8 +105,14 @@ namespace Kyoo.Controllers } } + /// + /// A base class for repositories. Every service implementing this will be handled by the . + /// public interface IBaseRepository : IDisposable, IAsyncDisposable { + /// + /// The type for witch this repository is responsible. + /// Type RepositoryType { get; } } diff --git a/Kyoo.Common/Controllers/Implementations/LibraryManager.cs b/Kyoo.Common/Controllers/Implementations/LibraryManager.cs index 366cb0ea..bd4a9f91 100644 --- a/Kyoo.Common/Controllers/Implementations/LibraryManager.cs +++ b/Kyoo.Common/Controllers/Implementations/LibraryManager.cs @@ -16,6 +16,10 @@ namespace Kyoo.Controllers private readonly IBaseRepository[] _repositories; + /// + /// Create a new instancce with every repository available. + /// + /// The list of repositories that this library manager should manage. If a repository for every base type is not available, this instance won't be stable. public LibraryManager(IEnumerable repositories) { _repositories = repositories.ToArray();