docs
docs copied to clipboard
fix 'Source on GitHub' links in API docs
The 'View on GitHub' links in the API documentation are all broken. I've used a quick script included below for reference to try and align them with the actual GitHub URLs.
<?php
foreach (glob('docs/en/api/phalcon_*.md') as $filename) {
$file = file_get_contents($filename);
preg_match_all('/tree\/v{{ page.version }}.0\/phalcon\/(.+)/', $file, $matches);
foreach ($matches[1] as $i => $match) {
$match = ucwords($match, '/');
$match = str_replace(
['adapter', 'application', 'array', 'aware', 'combined', 'common', 'component', 'element', 'exception', 'factory', 'field', 'handler', 'interface', 'manager', 'message', 'middleware', 'min.', 'model', 'pdo', 'request', 'validator', 'value'],
['Adapter', 'Application', 'Array', 'Aware', 'Combined', 'Common', 'Component', 'Element', 'Exception', 'Factory', 'Field', 'Handler', 'Interface', 'Manager', 'Message', 'Middleware', 'Min.', 'Model', 'Pdo', 'Request', 'Validator', 'Value'],
$match
);
$file = str_replace($matches[0][$i], "blob/{{ page.version }}.x/phalcon/$match", $file);
}
file_put_contents($filename, $file);
}
Thank you @adamharley
One comment:
The link should be .0
not .x
here:
blob/{{ page.version }}.x
@niden The branches use .x not .0 with the exception of 4.0.0_homebrew
e.g. https://github.com/phalcon/cphalcon/blob/4.0.x/phalcon/Acl/Adapter/AbstractAdapter.zep and https://github.com/phalcon/cphalcon/blob/4.1.x/phalcon/Acl/Adapter/AbstractAdapter.zep
@niden The branches use .x not .0 with the exception of
4.0.0_homebrew
e.g. https://github.com/phalcon/cphalcon/blob/4.0.x/phalcon/Acl/Adapter/AbstractAdapter.zep and https://github.com/phalcon/cphalcon/blob/4.1.x/phalcon/Acl/Adapter/AbstractAdapter.zep
I see what you are saying. The issue is that there is a 4.0.0 tag so that one would work. For the 4.1 we will need the x
.
I think we will be ok not to use the x
because 4.0.0 is the current docs and the 4.0.x branch is not guaranteed to stay in the repository in the future. 4.1 is a future release so we should be ok there also.
Bit confused, 4.0.0 as is won't work like: https://github.com/phalcon/cphalcon/blob/4.0.0/phalcon/Acl/Adapter/AbstractAdapter.zep
Bit confused, 4.0.0 as is won't work like: https://github.com/phalcon/cphalcon/blob/4.0.0/phalcon/Acl/Adapter/AbstractAdapter.zep
This one works for me
https://github.com/phalcon/cphalcon/blob/v4.0.0/phalcon/Acl/Adapter/AbstractAdapter.zep
I think the issue is the tag vs the branch. As you see in your example you include the potential branch name which might have existed at some point 4.0.0
. I include the release tag v4.0.0
which will always be there.
Now that we are pretty much at the end of 4.0.x and will be releasing 4.1.x we can have different versions of this URL, one targeting the tag (v4.0.0
) and one targeting the branch (4.1.x
)
Ah makes sense! I've changed the links accordingly and resolved some conflicts so should be good now.
@adamharley I will check this a bit later. Thanks for this.
I am wondering if we have to rename classes because I see different casing vs. what the actual class is (UploadedFile vs Uploadedfile)
Hi @niden, Links to the Github source are all broken...
Example: Page: https://docs.phalcon.io/5.0/en/api/phalcon_session There is a link: https://github.com/phalcon/cphalcon/blob/v.0/phalcon/Session/Adapter/AbstractAdapter.zep Should be: https://github.com/phalcon/cphalcon/blob/5.0.x/phalcon/Session/Manager.zep
Need to change v.0 to 5.0.x
This one has been addressed. Thank you @adamharley for the inspiration and work and @yesworld for the ping - there was a typo indeed for the links regarding the v5 documentation.
I need to check v4 and v3 links and then I will close this.
Thank you both for the hard work.
Ok just checked the v3 and v4 links. Since those are no longer in the translation engine, I hard coded those links.
We should be good now. Thank you again!