Skip to content
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

Generate facade docs using official Laravel Facade Documenter #252

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

stevebauman
Copy link
Contributor

While building URL's I noticed some methods were missing (such as the Conditionable trait methods, generateKeyUsing, etc.) and some return types being incorrect (returning self instead of Builder), so I generated the annotations using Laravel's official Facade Documenter via the below:

composer require stevebauman/autodoc-facades --dev
php -f vendor/bin/facade.php -- \
    AshAllenDesign\\ShortURL\\Facades\\ShortURL
composer remove stevebauman/autodoc-facades

Let me know if you'd like anything changed/adjusted. Thanks for your time! 🙏

@ash-jc-allen
Copy link
Owner

Hey Steve! Sorry for taking a while to get to this. I love this!

I've been really bad at keeping the facade up to date, so this will definitely come in handy.

Out of interest, do you know if there's a quick way I might be able to automate this more often? Maybe like running it as a GitHub Action to check that the facade docblock is up to date and fail the workflow if it's not? If that's possible, that's something I'd use for all my packages 😄

@ash-jc-allen ash-jc-allen merged commit c328015 into ash-jc-allen:master Apr 12, 2024
23 checks passed
@stevebauman
Copy link
Contributor Author

stevebauman commented Apr 12, 2024

Hey @ash-jc-allen! No worries at all.

Out of interest, do you know if there's a quick way I might be able to automate this more often?

Yea absolutely! We could use a GitHub action to install my autodoc-facades package, run the script, uninstall it (so it's not a dependency), then commit result. Something like this should work:

# .github/workflows/document-facades.yml

name: document-facades

on:
    push:
    pull_request:

jobs:
    autodoc-facades:
        runs-on: ubuntu-latest

        steps:
            - name: Checkout code
              uses: actions/checkout@v2

            - name: Setup PHP
              uses: shivammathur/setup-php@v2

            - name: Install dependencies
              run: composer install --no-interaction --prefer-dist --no-suggest

            - name: Install Autodoc Facades
              run: composer require stevebauman/autodoc-facades --dev

            - name: Document Facades
              run:
                  php -f vendor/bin/facade.php -- \
                      AshAllenDesign\\ShortURL\\Facades\\ShortURL

            - name: Remove Autodoc Facades
              run: composer remove stevebauman/autodoc-facades

            - name: Commit Docs
              uses: stefanzweifel/git-auto-commit-action@v4
              with:
                  commit_message: Apply facade changes

The reason why my package is required is because the core Laravel package can only be installed when your composer.json minimum-stability is set to dev. This allows potentially unstable packages to be installed, and could break / throw off your tests in this package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants