-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to diff DocC Archives #908
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At a high level I have some concerns about this command. Mainly I don't think that operating on already built documentation archives is going to be able to provide a good user experience.
Specifically, there are a handful of key issues that I foresee:
- The render node identifier isn't necessarily stable between versions. As such, API could incorreclty be flagged as both added and removed despite not having changed.
- The archive doesn't contain sufficient information to reconstruct a working symbol or documentation link to each added symbol.
- The archive doesn't contain sufficient information—at least not in a structured way that can easily be operated on—to group the added or removed symbols.
For example, if a type adds conformance toComparable
, it would be very difficult to present that information in a succinct and human friendly way, such as "Added conformance to Comparable", instead of listing the 5 new operators that can be called on that type (..<(_:)
,>(_:_:)
,<(_:_:)
,>=(_:_:)
,<=(_:_:)
) - Iterating the entire documentation archive directory structure to decode each page is both a very slow way of finding the differences and doesn't contain any information about pages that moved from one place to another.
- The archive doesn't contain sufficient information—at least not in a structured way that can easily be operated on—to identify other types of changes that would be relevant to list in a change log, for example API that still exist but was deprecated from one version to the next.
Sources/SwiftDocCUtilities/ArgumentParsing/Subcommands/DiffDocCArchive.swift
Outdated
Show resolved
Hide resolved
var removalLinks: String = "" | ||
for removal in removalsExternalURLs { | ||
removalLinks.append("\n- <\(removal)>") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming that the generated change log file is intended to be included in another build for the newer version of the documentation, it won't be possible to link to any symbols that have been removed because those are not in that version of the source anymore.
return returnSymbolLinks | ||
} | ||
|
||
func findSymbolLink(symbolPath: URL) throws -> URL? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This API (and also findAllSymbolLinks(initialPath:)
and findExternalLink(identifierURL:)
) doesn't return a value that can be used as a symbol link in DocC.
AFAIK there isn't a reliable way to go from a rendered page to a symbol page. You may need to rethink this approach and use another source of data if you're going to generate working markup files containing correct symbol links.
|
||
/// The framework name is the path component after "/documentation/". | ||
func findFrameworkName(initialPath: URL) throws -> String? { | ||
guard let enumerator = FileManager.default.enumerator( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use our FileManagerProtocol
abstraction---instead of FileManager.default
directly---to be able to write tests that don't interact with the real file system.
Sources/SwiftDocCUtilities/ArgumentParsing/Subcommands/DiffDocCArchive.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftDocCUtilities/ArgumentParsing/Subcommands/DiffDocCArchive.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftDocCUtilities/ArgumentParsing/Subcommands/DiffDocCArchive.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftDocCUtilities/ArgumentParsing/Subcommands/DiffDocCArchive.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftDocCUtilities/ArgumentParsing/Subcommands/DiffDocCArchive.swift
Outdated
Show resolved
Hide resolved
Sources/SwiftDocCUtilities/ArgumentParsing/Subcommands/DiffDocCArchive.swift
Outdated
Show resolved
Hide resolved
a21dba3
to
bc41ccc
Compare
…ls within the first DocC Archive, (2) The existing symbols within the second DocC Archive, and (3) The new symbols added to the second DocC Archive that did not exist in the first DocC Archive
…tions and removals.
…s, and structs; and include --show-all flag for more granular symbol diff (i.e. all symbols that have changed).
bc41ccc
to
05b5e76
Compare
Bug/issue #, if applicable:
Summary
Adds a command line option for processing DocC Archives, producing a diff between two different versions of DocC Archives for the same framework or technology.
This diff contains a list of symbols added/removed between the two versions, and is stored in an output markdown file called
{FrameworkName}_ChangeLog.md
that will be written to the same directory as the input files.The output markdown page can then be copy-pasted into the corresponding project and built as an article alongside the other documentation, serving as a starting point for writing change logs or updates pages.
To run this script, run the following command:
Dependencies
N/A
Testing
Steps:
Run this command locally to diff two releases for a given framework, by passing in two local DocC Archives.
For example:
swift run docc process-archive diff-docc-archive "Release 1" /path/to/local/doccarchive/ "Release 2" /path/to/local/doccarchive2/
Ensure that a new markdown file has been generated at the top level of the first DocC archive. This should be titled {FrameworkName}_ChangeLog.md (or NoFrameworkFound_ChangeLog.md if the framework name was not found).
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/test
script and it succeeded