xrnx icon indicating copy to clipboard operation
xrnx copied to clipboard

Html documentation generation requires legacy PHP

Open jcpst opened this issue 9 years ago • 3 comments

I tried running the documentation generator and the following error occurred:

PHP Warning:  preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/joe/git/xrnx/Xtra/HtmlGen/api_to_html.php on line 152

And it spit out .html pages with no documentation.

I have PHPv7 on my machine. I've never touched PHP code before, so I looked at their docs and found this.

So I changed api_to_html.php at L152 to this:

$markdown = preg_replace_callback(
    '/(={4,}|-{4,})\n(.*?)(={4,}|-{4,})\n/s',
    function ($m) {
        return "header_transform('$m[1]', '$m[2]')";
    },
    $markdown
);

And it worked...mostly. The header_transform function came out as plain text on the .html page:

header_transform('============================================================================', 'Renoise Script Debugging HowTo ') In addition to the usual print....

jcpst avatar Jan 21 '16 22:01 jcpst

It's a warning, not an error. You can suppress it using the @ character. Example:

$markdown = @preg_replace('/(={4,}|-{4,})\n(.*?)(={4,}|-{4,})\n/se', "header_transform('$1', '$2')", $markdown);

For your fix: header_transform is a function in global space found a bit higher up in the file (line ~51). You must remove the quotes which is converting it to a string. Try:

$markdown = preg_replace_callback(
    '/(={4,}|-{4,})\n(.*?)(={4,}|-{4,})\n/s',
    function ($m) {
        return header_transform('$m[1]', '$m[2]');
    },
    $markdown
);

dac514 avatar Jan 21 '16 22:01 dac514

Yep, raised this issue too soon, just figured out that fix myself. Thank you!

To get api_to_html.php building the docs with PHP7, Would it be preferable to suppress the warning, or update that statement?

jcpst avatar Jan 21 '16 22:01 jcpst

Updating the statement is preferable. :)

dac514 avatar Jan 21 '16 22:01 dac514