How to use help to show documentation for pcode version of a MATLAB class

2 Ansichten (letzte 30 Tage)
Hello,
I would like to generate p-code for a class file, and to have the MATLAB 'help' command actually return the help content that is generated from before the file was p-coded. Is this possible?
%
classdef SampleClass < handle
% myClass Summary of myClass
% This is the first line of the description of myClass.
% Descriptions can include multiple lines of text.
%
% myClass Properties:
% a - Description of a
% b - Description of b
%
% myClass Methods:
% doThis - Description of doThis
% doThat - Description of doThat
properties
RootProperty = 1;
end
methods
function obj = SampleClass()
obj.RootProperty = 4;
end
end
The output from the command line is this, before and after I delete the source file (the point is to secure the source file, but still have the help available):
>> help SampleClass
myClass Summary of myClass
This is the first line of the description of myClass.
Descriptions can include multiple lines of text.
myClass Properties:
a - Description of a
b - Description of b
myClass Methods:
doThis - Description of doThis
doThat - Description of doThat
Reference page for SampleClass
>> pcode('SampleClass.m')
>> delete('SampleClass.m')
>> help SampleClass
No help found for SampleClass.
>>

Antworten (1)

Jan
Jan am 5 Jun. 2018
You can find many tools for this job in the FileExchange: FEX: Search "pcode help".
These tools crop the help section out of the M-function at first, P-code the contents of the function and create an M-file, which contains the help section only.
By the way, do not overestimate the security level of P-coding. You cannot read the code anymore, but reverse-engineering with the debugger is not too complicated. As long as you do not have a contract with your customers which forbid this, reverse-engineering is not illegal.
  1 Kommentar
Walter Roberson
Walter Roberson am 5 Jun. 2018
help always looks for the .m file to extract the documentation. It will never look inside the .p to see if there was help documentation available in the original .m .

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by