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

7 次查看(过去 30 天)
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.
>>

回答(1 个)

Jan
Jan 2018-6-5
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 个评论
Walter Roberson
Walter Roberson 2018-6-5
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 .

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by