Support Forum

Codex – API Function Entries

YS Yellow Swordfish
Yellow Swordfish
Member

Steve – you asked me a few days ago about the format of the sp_get_auth() api function entry that you created as a starter. Thought I would answer that here with my comments and thoughts. So – in no particular order…

  1. Need to add the initial version number (see another topic)
  2. Inconsistent use of argument variable names – particularly $id and $forumid. Reckon we need to be very explicit and consistent on this in each function and across all functions. Same goes for $check? Would not $permission be a better variable name to use?
  3. What happened to the formatted code examples? They looked good when you used them before…
  4. Perhaps a pain but I would suggest a new sub-section of ‘Scope’ where we can document if the file is loaded globally on the site or just on forum pages.
  5. And – specific to this one and just as a reminder – I think we will need to list the actual permission names or at least have a link to them somewhere.

10 Answers

New Answer

MP Mr Papa
Mr Papa
Member

Andy, can you take a shot at updating the sp_get_auth() codex entry to see it in practice?

#2 are you suggesting going back through the code and changing variable names?

#3 formatted code examples?  do you mean syntax highlighter?  forgot about it will change to that and see if its what you meant…

#5 I dont think we should list the permissions there.  perhaps a new section under simple press api? I think that would be appropriate…

MP Mr Papa
Mr Papa
Member

updated the sp_get_auth() example to use the code display…  think I like it better!

Brandon, fyi, to do that, in the visual editor, you will see an icon that looks like a highlighter… select it, pick the language and then paste in the code you want to highlight…

BR Brandon
Brandon
Member

Looks like a highlighter?

Here is what I see using the visual editor and turning on ‘kitchen sink’

2011-11-05_2309.png

Is that the same as you see? Which one is the highlighter?

MP Mr Papa
Mr Papa
Member

hmmm… maybe not available to your role… have increased role to editor… please check again…

YS Yellow Swordfish
Yellow Swordfish
Member

#2 – Eh? I am talking about this codex entry and the use of the variable names in the text.

For example you have used $id in the definition at the top and $forumid in the examples. This should be consistently $forumid. Same with the use of $user_id and $userid. And I was suggesting that $check would be better if it described the item in question… in this case $permission.

#4 – Any comments on this one?

MP Mr Papa
Mr Papa
Member

#2 I think it would be a mistake to change only the codex entry in that manner.  Then it would not agree with the code itself…  which is why I asked if you were suggesting to change the code…  the variables used, $check, $id, $userid are exactly what is used in the code…  I think the codex entry variables should match the code variables…

#4 fine with it… silence was concurrence… wink

YS Yellow Swordfish
Yellow Swordfish
Member

Mr Papa said

#2 I think it would be a mistake to change only the codex entry in that manner.  Then it would not agree with the code itself…  which is why I asked if you were suggesting to change the code…  the variables used, $check, $id, $userid are exactly what is used in the code…  I think the codex entry variables should match the code variables…

I very strongly disagree with this. This is documentation. If the codex is clear, precise and consistent there is no need for anyone to ever look at the code itself. We are talking about function parameters and the way to make them clear, usable, unequivocal and unambiguous is to describe them properly with meaningful names.

Using shortened variable names in code is one thing (although I do try and use the full terms like ‘forumid’, ‘topicid’, ‘userid’ in my code as much as possible). Using ambiguous variable names in documentation is just confusing. To then go on to cite examples that do not even use the same variable names as those in the definition at the top is likely to totally confuse the less able and skilled.

If you prefer to go through the code and change variable names in there then I say yes – we need to do it. But personally I see no need whatsoever to do so.

MP Mr Papa
Mr Papa
Member

wow. surprised.smile

wouldnt have thought you would be for the documentation not matching the code…

btw, all the names on that example codex entry were already changed a day or two ago to be consistent with each other – so not really part of the discussion since already agreed and to and changed…

the only question left is whether the docs match the code in variable names…  If everyone else is good with them not, I can certainly get over it…laugh

BR Brandon
Brandon
Member

Mr Papa said

hmmm… maybe not available to your role… have increased role to editor… please check again…

I do see it now, thanks.