ash-jc-allen / short-url

A Laravel package for creating shortened URLs for your web apps.
MIT License
1.25k stars 158 forks source link

Generate facade docs using official Laravel Facade Documenter #252

Closed stevebauman closed 5 months ago

stevebauman commented 5 months ago

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 commented 5 months ago

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 😄

stevebauman commented 5 months ago

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.