-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch, updates and refactor for improved
magefiles
upkeep and docum…
…entation. Summary: **Added:** - `magefiles/README.md` - New README for the `magefiles` directory detailing functions, usage examples, and contributing guidelines. - `magefiles/tmpl/README.md.tmpl` - Enhanced template for more descriptive README files for the `magefiles` package. - `docgen.go` - Extracted documentation generation logic from `magefile.go`. - `testing.go` - Segregated testing-related functions from `magefile.go`. **Changed:** - `.tool-versions` - Updated Go to version 1.21.3 and Python to version 3.12.0. - `magefiles/tmpl/README.md.tmpl` - Adjusted for better `magefiles` package documentation structure. - `magefile.go` - Split code into multiple files for easier maintenance and better organization. - Patched older net library for enhanced security and performance. Differential Revision: D50618372
- Loading branch information
1 parent
ec7be0a
commit 09d5cfb
Showing
7 changed files
with
532 additions
and
453 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//go:build mage | ||
// +build mage | ||
|
||
/* | ||
Copyright © 2023-present, Meta Platforms, Inc. and affiliates | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
|
||
"github.com/l50/goutils/v2/docs" | ||
"github.com/l50/goutils/v2/git" | ||
"github.com/l50/goutils/v2/sys" | ||
"github.com/spf13/afero" | ||
) | ||
|
||
// GeneratePackageDocs creates documentation for the various packages | ||
// in the project. | ||
// | ||
// Example usage: | ||
// | ||
// ```go | ||
// mage generatepackagedocs | ||
// ``` | ||
// | ||
// **Returns:** | ||
// | ||
// error: An error if any issue occurs during documentation generation. | ||
func GeneratePackageDocs() error { | ||
fs := afero.NewOsFs() | ||
|
||
repoRoot, err := git.RepoRoot() | ||
if err != nil { | ||
return fmt.Errorf("failed to get repo root: %v", err) | ||
} | ||
sys.Cd(repoRoot) | ||
|
||
repo := docs.Repo{ | ||
Owner: "facebookincubator", | ||
Name: "ttpforge", | ||
} | ||
|
||
templatePath := filepath.Join(repoRoot, "magefiles", "tmpl", "README.md.tmpl") | ||
// Set the packages to exclude (optional) | ||
excludedPkgs := []string{"main"} | ||
if err := docs.CreatePackageDocs(fs, repo, templatePath, excludedPkgs...); err != nil { | ||
return fmt.Errorf("failed to create package docs: %v", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.