refactor: refactoring yuque connector #62
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do
This pull request introduces several changes to the
plugins/connectors/yuque
package, primarily focusing on enhancing the collection and indexing of book table of contents (TOC) and improving error handling. The most important changes include the addition of a new structBookToc
, modifications to thecollectBooks
andcollectDocs
functions to handle TOC data, and the addition of a new configuration option to skip TOC indexing.Enhancements to book TOC handling:
plugins/connectors/yuque/book.go
: Added a new structBookToc
to represent the table of contents of a book, including fields for UUID, type, title, URL, and hierarchical relationships.Modifications to collection functions:
plugins/connectors/yuque/collect.go
: Updated thecollectBooks
function to fetch and process the book TOC, creating a map of folder paths for documents. Introduced a temporary structFolderInfo
for sorting purposes. [1] [2]plugins/connectors/yuque/collect.go
: Modified thecollectDocs
andcollectDocDetails
functions to accept the TOC map and include TOC information in the document metadata. [1] [2] [3]Error handling improvements:
plugins/connectors/yuque/collect.go
: Enhanced error handling in theget
function by usingerrors.Errorf
to provide more detailed error messages when an HTTP request fails.New configuration option:
plugins/connectors/yuque/plugin.go
: Added a new configuration optionSkipIndexingBookToc
to allow users to skip the indexing of book TOC if desired.Rationale for this change
Standards checklist