- Overview
- Transcript
4.9 DocBlockr
If you work in a language or framework that really encourages the process of commenting your code, you'll certainly want to leverage the DocBlockr plugin.
1.Introduction1 lesson, 02:05
1.1Welcome02:05
2.Getting Started9 lessons, 35:20
2.1Installation and Base Settings04:54
2.2Services and Opening Sublime From the Terminal02:20
2.3Multiple Cursors and Incremental Search06:54
2.4The Command Palette04:13
2.5Instant File Changing03:19
2.6Symbols04:17
2.7Key Bindings02:33
2.8Installing Plugins Without Package Control02:54
2.9Package Control03:56
3.Snippets3 lessons, 14:40
3.1Your First Snippet09:04
3.2Adding Snippets Through Package Control02:32
3.3Easier Testing With Snippets03:04
4.Essential Plugins12 lessons, 46:58
4.1Zen Coding07:09
4.2Emmet06:52
4.3Cross-Browser CSS With Prefixr02:17
4.4Fetch Files With Ease 04:22
4.5Lightning Fast Folder and File Creation 02:12
4.6Sidebar Enhancements03:09
4.7Sublime Linter02:01
4.8Sexy Code Snippet Management With Gists07:50
4.9DocBlockr03:49
4.10Pretty Task Management02:42
4.11HTTP Requests Within Sublime02:29
4.12LiveReload02:06
5.Tips, Techniques and Modifications8 lessons, 49:09
5.1Regular Expressions in Sublime05:49
5.2Vintage Mode10:46
5.3Quicker Stylesheet References02:30
5.4Joining Lines04:40
5.5Sublime and Markdown with Marked03:10
5.6All About Projects 05:54
5.7Configuring and Mastering Split Windows07:19
5.8Custom Builds09:01
6.Closing1 lesson, 00:49
6.1Conclusion00:49
4.9 DocBlockr
If you happen to work in a language or framework that really encourages commenting your code, the DocBlockr plugin is for you. We install it through Package Control. I will look for DocBlockr and there we go. Give it a few seconds and now we're ready to work with it. So let's create a file to work with. I will save this as, my-class.php. And within here, let's create a class. Class MyClass, like so. Now let's add a function, maybe we will call it run. For the arguments, maybe we'll accept the person who should be running and how far. Something like that will be fine. So now, we're just going to use pseudocode. We'll say, Return. Person needs to run how far miles. All right. That looks fine. So now watch what happens if before the method, I do forward slash and then two stars and hit Tab. With the DocBlocker plugin, this will immediately expand. And this is doing more than you think. It's not just giving you a snippet. It's also grabbing the params. So notice that it looked ahead and saw, hey, we're accepting a person and how far, so it populates two params. If I backtrack and we add an additional param, maybe direction or something like that. When I do it again, now it's going to give us three params. So then at this point, I can give the function a name. Instruct a person to run for a while. If I hit Tab again, its going to incrementally tab through each of those. So this first one will be a string, the description, we can leave that blank. The next one will be an integer, we'll leave that one blank and the final one is a string as well. Finally, what are we returning? We're going to return a string and now we're done. Now what's cool is that this DocBlockr plugin is fairly smart. So for example, if we add comments above the class, well, it's going to know, all right. We're not working with the method here, we're just describing the class. So let's take this just a little bit further to show you some of the other options that it provides. If I delete this entirely, watch what happens if I said a default value. So maybe the default person to run will be John Doe. Well, now if I run it, the plugin is going to detect that. Realize that its default value is a string and it will auto-populate the type for you for that specific parameter. Or if I backtrack just a ways, maybe we're going to make a handful of people run. Well, in that case, I'll set the name to people and then I'm going to typecast this in php, which says, we're expecting an array. And then to make this work, maybe we will do implode using a comma, the people's array and then we will concatenate on the rest. That looks fine and you know what? We're not really using direction here, so I'll get rid of that. So now that we've added type hinting, if I do it one more time, once again, the plugin is going to detect that and auto-populate the type for you. Now when it comes to the return value, the plugin will do a handful of things for you. So let me show you. Let's create another function, we'll say, isRunning and we will just return false or an empty string. It doesn't matter, really in this case. But the key is that we have the word is within the method name. So now when I run it, the plugin's going to detect that it has is in it and it knows that it's going to return a Boolean, likely. The same thing, I believe for has because typically, when you name methods in that way, a Boolean will be returned, so it knows to do that for you. Now this extends to a variety of things. So maybe if we have a function for setPerson, person. And then something like this, person equals person. Now when we run the plugin on that, it's going to realize that we are doing a set. We're using a setter method here, so nothing should be returned. And as you can see, it's not. So there's a couple other things that this plugin can do, but I leave it to you to figure that out for yourself. Let's move on to the next lesson now.